SQL显示前3名最高薪水 [英] SQL to show top 3 maximum salary
本文介绍了SQL显示前3名最高薪水的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设有一个表Employee,其中包含列Id(主键),Name和Salary。如何显示3行薪水最高的员工?
Let''s say there is a table Employee with columns Id (primary key), Name and Salary. How can I display 3 rows of employees with the highest salaries?
推荐答案
尝试这样的事情:
Try something like this:
SELECT TOP(3) [ID], [Name], MAX([Salary])
FROM YourTable
GROUP BY [ID], [Name]
ORDER BY [Salary] DESC
select top 3 Name,Salary from Employee order by Salary desc
由shiny13编辑:Oracle equ ivalent to Top是Rownum,对于MySQL来说是极限。
Edit by shiny13: Oracle equivalent to Top is Rownum, for MySQL its limit.
这篇关于SQL显示前3名最高薪水的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文