2021. máj 28.

Leetcode 185: Department Top Three Salaries: My Solution

írta: dataanalyticsdemo
Leetcode 185: Department Top Three Salaries: My Solution

Free sample test question II.

with combined as (
select E.*, D.name as dep_name
from employee E
left join department D
on E.departmentid = d.id
),

ranked as (
select *
,dense_rank() over (partition by dep_name order by salary desc) as rn
from combined
)

select
dep_name as department,
name as Employee,
salary as Salary
from ranked where rn <= 3

Szólj hozzá