例子1:获取 Employee 表中第二高的薪水(Salary),没有第二高的则返回null
select ifnull((select distinct Salary from Employee order by Salary desc limit 1, 1), null) as SecondHighestSalary;
解析:
ifnull(A, B) : 如果A不为空则返回A,为空则返回B
distinct Salary : 单独获取Salary 列,并且去除重复
limit a, b : 排序后从a行开始,总共拿b个数据。a从0 开始计