如何从这张表中选择最后7个最高工资?

时间:2011-07-22 06:45:18

标签: sql

NAME                        AGE     DEPTNO     SALARY
-------------------- ---------- ---------- ----------
shasank                      25         11       2025
raju                         27         12       2027
bali                         31         10       2031
rambo                        32         11       2121
chir                         34         10       2123
son                          33         12       2131
don                          33         11       2132
ram                          28         13       2141
nag                          35         10       2213
dimpu                        33         12       2314

3 个答案:

答案 0 :(得分:4)

SELECT * FROM yourTable ORDER BY SALARY DESC LIMIT 7

答案 1 :(得分:3)

select top(7) *
from table
order by salary desc

答案 2 :(得分:1)

MS SQL:

SELECT TOP 7 salary FROM table1 GROUP BY salary

MySQL的:

SELECT salary FROM table1 GROUP BY salary LIMIT 0,7