关键字附近的语法不正确'其中' for dense_rank()

时间:2017-07-31 13:49:33

标签: sql-server sql-server-2016

select * from (select e.*, dense_rank() over (order by salary desc) as rk from employee e) 
where rk>=5

我遇到语法错误

  

关键字'其中'。

附近的语法不正确

问题是什么?

1 个答案:

答案 0 :(得分:3)

试试这个:

select * from (select e.*, 
                      dense_rank() over (order by salary desc) as rk 
               from employee e
               ) tmp  --alias to from subquery
where tmp.rk>=5
希望这有帮助!