查询时获取以下错误消息 窗口函数只能出现在SELECT或ORDER BY子句中。
SELECT A.FULLNAME,A.RLOTEAM,A.rloFunction,A.tfalUserID
,IIF(dd.datekey between CONVERT(VARCHAR(19),CONVERT(DATETIME,A.validFrom,3),112)
and CONVERT(VARCHAR(19),CONVERT(DATETIME,A.validto,3),112),'Yes','No') AS iiscurrent
,RANK() OVER ( PARTITION BY A.tfalUserID ORDER BY A.id DESC ) AS rk
FROM
dsfact.RosterAdherence fa
INNER JOIN
DIM.RLO_Staff A ON FA.Agent=A.fullName AND FA.Team=A.rloTeam
INNER JOIN
dim.Dates dd ON fa.DateKey = dd.DateKey
GROUP BY
A.FULLNAME,A.RLOTEAM,A.rloFunction,A.tfalUserID
,IIF(dd.datekey between CONVERT(VARCHAR(19),CONVERT(DATETIME,A.validFrom,3),112)
and CONVERT(VARCHAR(19),CONVERT(DATETIME,A.validto,3),112),'Yes','No')
,RANK() OVER ( PARTITION BY A.tfalUserID ORDER BY A.id DESC )
预期: 我希望避免填充重复项。