【leetcode】176. 第二高的薪水

題目:
答案:
1
# Write your MySQL query statement below  
select IFNULL((select Distinct Salary from Employee order by Salary DESC limit 1,1),null) as SecondHighestSalary 
2
# Write your MySQL query statement below  
select max(Salary) as SecondHighestSalary from Employee where Salary<(select max(Salary) from Employee) 

筆記:
LIMIT:
select * from Customer LIMIT 10;--檢索前10行數據,顯示1-10條數據
select * from Customer LIMIT 1,10;--檢索從第2行開始,累加10條id記錄,共顯示id爲2....11
select * from Customer limit 5,10;--檢索從第6行開始向前加10條數據,共顯示id爲6,7....15
select * from Customer limit 6,10;--檢索從第7行開始向前加10條記錄,顯示id爲7,8...16
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章