开发者

How to list out Top 10 salaries with out using TOP

How can i display Top 10 salaries from a ta开发者_运维技巧ble with out using TOP


Try this

SELECT  Salary
from
(
  SELECT  Salary, Row_Number() OVER(ORDER BY SALARY desc) AS 'Salaries'
FROM User2
)#emp 
  WHERE  Salaries <=10 order by salary desc


You can use ROW_NUMBER OVER ( order by ... )

SELECT t.sal from
(
  SELECT  sal, Row_Number() OVER (ORDER BY sal desc) AS rownum
  FROM table
) t 
WHERE  t.rownum <= 10 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜