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 |
반응형
'SQL' 카테고리의 다른 글
leetcode 577. Employee Bonus (0) | 2023.04.12 |
---|---|
leetcode 1327. List the Products Ordered in a Period (0) | 2023.04.08 |
leetcode 1251. Average Selling Price (0) | 2023.04.07 |
leetcode 2356. Number of Unique Subjects Taught by Each Teacher (0) | 2023.04.06 |
leetcode 1378. Replace Employee ID With The Unique Identifier (0) | 2023.04.06 |
댓글