以下查询:
SELECT ROW_NUMBER() OVER(ORDER BY sum(salary) DESC) as num,id, sum(salary) as salary
FROM person
GROUP BY id
where num=3;
在where
条件下给我一个错误,我希望获得第3行数据......对此有什么解决方法?
答案 0 :(得分:0)
你需要一个子查询:
Finish
(好吧,除非您使用Teradata并且可以使用select p.*
from (select ROW_NUMBER() OVER (ORDER BY sum(salary) DESC) as num, id,
sum(salary) as salary
from person
group by id
) p
where num = 3;
子句。)