Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 091a35b

Browse files
Primary Department for Each Employee
1 parent 3860108 commit 091a35b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Link: https://leetcode.com/problems/primary-department-for-each-employee/
2+
Tool: MS SQL Server
3+
4+
5+
6+
7+
8+
9+
select distinct e.employee_id, e.department_id
10+
from Employee e
11+
where e.primary_flag = 'Y' or
12+
1 = (select count(department_id) from Employee where employee_id = e.employee_id);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /