对于以下查询,我收到“未返回任何结果”:
SELECT
Referer
FROM
(SELECT
ROW_NUMBER() OVER (ORDER BY CT.Referer ASC) AS RowNum,
CT.Referer, CT.LastModified
FROM
ClickTrack CT
JOIN
OrderTrack OT ON OT.ClickTrackID = CT.ClickTrackID
GROUP BY
CT.Referer, CT.LastModified
HAVING
LEN(CT.Referer) > 0) as num
WHERE
RowNum = 1
AND LastModified BETWEEN '07/06/2013' and '08/05/2013'
奇怪的是,当我离开时RowNum = 1
,我得到了完整的值列表。我需要一次得到一个,但要分配给一个变量并放入一个临时表中。
结束查询将在 while 循环中使用标量变量代替日期范围和RowNum
比较。
任何帮助表示赞赏。谢谢!