File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff 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 )
66672 . [ 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 )
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments