176. Second Highest Salary

Leetcode 问题: 176. Second Highest Salary

题目

找出 Employee 资料表第二高薪的薪水

  • 若没有第二高薪水的话则回传 null
  • 若第一高有两个人,薪水一样高,但没其他人了,则第二高为 null

Employee 资料表

Id Salary
1 100
2 200
3 300
4 100
# Write your MySQL query statement below
SELECT(
  SELECT DISTINCT `Salary`
  FROM `Employee`
  ORDER BY `Salary` DESC
  LIMIT 1 OFFSET 1
) as `SecondHighestSalary`