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
精彩评论