---
# System prepended metadata

title: \#176 Second Highest Salary
tags: [leetcode, leetcode-easy, sql]

---

# \#176 Second Highest Salary
## *取得排名2的資料列(無則回傳null)*
## Log
 - build 20210414 by syhuang

## 易理解的解答
 - 學習limit用法, 與sql回傳無資料列時為空字串(外層加一select使其回傳null)
```sql=
select(
select distinct Salary
from Employee
order by Salary Desc
limit 1,1)
as SecondHighestSalary
```

## 備註
 - LIMIT取Nth資料列的方法
 - 無資料列回傳null(無資料列預設是回傳空字串)
## 參考
 - https://leetcode.com/problems/second-highest-salary/discuss/52952/A-Simple-Answer
###### tags: `leetcode`, `leetcode-easy`, `sql`