如何使用TOP
显示表格中的前10名工资答案 0 :(得分:2)
试试这个
SELECT Salary
from
(
SELECT Salary, Row_Number() OVER(ORDER BY SALARY desc) AS 'Salaries'
FROM User2
)#emp
WHERE Salaries <=10 order by salary desc
答案 1 :(得分:1)
您可以使用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