Select*fromSalary;+--------+--------+|Name |Salary|+-- ------+--------+|Gaurav| 50000||Rahul | 40000||Ram | 45000||Raman | 45000|+----"/> Select*fromSalary;+--------+--------+|Name |Salary|+-- ------+--------+|Gaurav| 50000||Rahul | 40000||Ram | 45000||Raman | 45000|+----">

Home  >  Article  >  Database  >  How can we get the second highest salary of an employee from a MySQL table?

How can we get the second highest salary of an employee from a MySQL table?

王林
王林forward
2023-08-25 22:09:251000browse

我们如何从 MySQL 表中获取员工第二高的工资?

To understand this concept, we use the data from table "Salary" as follows -

mysql> Select * from Salary;
+--------+--------+
| Name   | Salary |
+--------+--------+
| Gaurav |  50000 |
| Rahul  |  40000 |
| Ram    |  45000 |
| Raman  |  45000 |
+--------+--------+
4 rows in set (0.00 sec)

mysql> Select * from salary12345 order by salary DESC limit 1 offset 1;
+-------+--------+
| name  | Salary |
+-------+--------+
| Raman |  45000 |
+-------+--------+
1 row in set (0.00 sec)

The above is the detailed content of How can we get the second highest salary of an employee from a MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete