Skip to content

Commit c9d0222

Browse files
authored
Create count-student-number-in-departments�.sql
1 parent 99bc5a1 commit c9d0222

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+
# Time: O(s+dlogd)
2+
# Space: O(d+s)
3+
4+
SELECT
5+
dept_name, COUNT(student_id) AS student_number
6+
FROM
7+
department
8+
LEFT JOIN
9+
student ON department.dept_id = student.dept_id
10+
GROUP BY department.dept_name
11+
ORDER BY student_number DESC , department.dept_name
12+
;

0 commit comments

Comments
 (0)