我在此查询中收到错误
select ID, ROW_NUMBER() OVER(ORDER BY ID) as num from T_TASK where ROW_NUMBER() = 5
和这一个
select ID, ROW_NUMBER() OVER(ORDER BY ID) as num from T_TASK where num = 4
查询有什么问题?
答案 0 :(得分:6)
使用子查询:
SELECT ID
FROM (
SELECT ID, ROW_NUMBER() OVER(ORDER BY ID) AS num
FROM T_TASK
) T1 WHERE num = 5
答案 1 :(得分:6)
SELECT ID
FROM
(select ID, ROW_NUMBER() OVER(ORDER BY ID) as rownum from T_TASK) dr
WHERE rownum = 5
答案 2 :(得分:0)
1您不能直接在WHERE子句上使用Windows函数
2同样适用于别名