https://leetcode.com/problems/department-top-three-salaries/description/
Department Top Three Salaries - LeetCode
Department Top Three Salaries - Table: Employee +--------------+---------+ | Column Name | Type | +--------------+---------+ | id | int | | name | varchar | | salary | int | | departmentId | int | +--------------+---------+ id is the primary key column for
leetcode.com
sql문제는 어려워...
같은부서에 속하는 사람들중 나보다 더 큰 사람들의 월급의 distinct 개수가 3개 미만인 것만 뽑으면 된다.
select d.name as 'Department', e.name as 'Employee', e.salary as 'Salary'
from Employee e
join Department d
on e.departmentId = d.id
where 3 > (select count(distinct(e2.salary))
from Employee e2
where e2.salary > e.salary
and e.departmentId = e2.departmentId)
물론 말이쉽지 나도 보고했다.
'코딩 테스트 및 알고리즘 > leetcode for google' 카테고리의 다른 글
leetcode hard : Unique Paths III (1) | 2023.01.22 |
---|---|
leetcode hard : Human Traffic of Stadium (0) | 2023.01.22 |
leetcode hard : Similar String Groups (0) | 2023.01.22 |
leetcode hard : Burst Balloons (0) | 2023.01.22 |
leetcode hard : Remove Invalid Parenthesis (1) | 2023.01.22 |