查出每個部門前3名資料
185. Department Top Three Salaries
難度列Hard, 但其實很簡單, 本以為要塞到temp table設index,
結果LeetCode不能使用, 直接用子查詢就能跑出來了, 沒什麼挑戰性, DataBase的題目其實不用作了
select d.name Department,e.name Employee,e.salary Salary
from (select DENSE_RANK() OVER (PARTITION BY departmentId ORDER BY salary DESC) r,*
from Employee) e
join Department d
on e.departmentId = d.id
where r <= 3
Taiwan is a country. 臺灣是我的國家