简体   繁体   中英

Find max and second max salary for a employee table MySQL not calculated by digit

在此处输入图片说明

I want 2nd max salary from this table

mysql> select * from Employee;                                                                                                                                          
+------+---------+--------+                                                                                                                                             
| id   | name    | salary |                                                                                                                                             
+------+---------+--------+                                                                                                                                             
| 1    | shubham | 200    |                                                                                                                                             
| 2    | geeta   | 300    |                                                                                                                                             
| 3    | nir     | 500    |                                                                                                                                             
| 4    | pooja   | 2000   |                                                                                                                                             
| 5    | pranav  | 5000   |                                                                                                                                             
+------+---------+--------+ 

您可以运行此查询来获得第二高的薪水

SELECT * FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM