176_Second Highest Salary
Write a SQL query to get the second highest salary from theEmployee
table.
For example, given the above Employee table, the query should return200
as the second highest salary. If there is no second highest salary, then the query should returnnull
.
Solution
Note
We use IFNULL(expr1, expr2)
to return NULL
when there is no second highest salary.
Ifexpr1
_is notNULL
,IFNULL()
returnsexpr1
; otherwise it returnsexpr2
_.
Last updated