본문 바로가기
SQL

leetcode 1789. Primary Department for Each Employee

by 무적김두칠 2023. 4. 8.

https://leetcode.com/problems/primary-department-for-each-employee/description/

 

Primary Department for Each Employee - LeetCode

Can you solve this real interview question? Primary Department for Each Employee - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

 

1
2
3
4
5
6
7
8
9
# Write your MySQL query statement below
(select employee_id, department_id
from Employee
where primary_flag = 'Y' )
union
(select employee_id, department_id
from Employee
group by employee_id
having  count(department_id) = 1)
cs
반응형

댓글