Skip to content

Commit 642cd52

Browse files
committed
task: #2356
1 parent d807e3f commit 642cd52

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Have a good contributing!
6363
- [1729. Find Followers Count](./leetcode/easy/1729.%20Find%20Followers%20Count.sql)
6464
- [1741. Find Total Time Spent by Each Employee](./leetcode/easy/1741.%20Find%20Total%20Time%20Spent%20by%20Each%20Employee.sql)
6565
- [1965. Employees With Missing Information](./leetcode/easy/1965.%20Employees%20With%20Missing%20Information.sql)
66+
- [2356. Number of Unique Subjects Taught by Each Teacher](./leetcode/easy/2356.%20Number%20of%20Unique%20Subjects%20Taught%20by%20Each%20Teacher.sql)
6667
2. [Medium](./leetcode/medium/)
6768
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
6869
- [184. Department Highest Salary](./leetcode/medium/184.%20Department%20Highest%20Salary.sql)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Question 2356. Number of Unique Subjects Taught by Each Teacher
3+
Link: https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/description/?envType=study-plan-v2&envId=top-sql-50
4+
5+
Table: Teacher
6+
7+
+-------------+------+
8+
| Column Name | Type |
9+
+-------------+------+
10+
| teacher_id | int |
11+
| subject_id | int |
12+
| dept_id | int |
13+
+-------------+------+
14+
(subject_id, dept_id) is the primary key (combinations of columns with unique values) of this table.
15+
Each row in this table indicates that the teacher with teacher_id teaches the subject subject_id in the department dept_id.
16+
17+
18+
Write a solution to calculate the number of unique subjects each teacher teaches in the university.
19+
20+
Return the result table in any order.
21+
*/
22+
23+
SELECT
24+
teacher_id,
25+
COUNT(DISTINCT subject_id) AS cnt
26+
FROM Teacher
27+
GROUP BY teacher_id

0 commit comments

Comments
 (0)