开发者

How to list out Top 10 salaries with out using TOP

开发者 https://www.devze.com 2023-02-14 18:13 出处:网络
How can i display Top 10 salaries from a ta开发者_运维技巧ble with out using TOPTry this SELECTSalary

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

精彩评论

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