Count Student Number in Departments
What if the student has an undeclared major? The dept_id in the student table could be null.
No one has replied
why not count student id? There may be duplicated names in fact.
@john700 said in Right join:
SELECT D.dept_name AS dept_name, COUNT(S.student_id) AS student_number FROM student AS S
RIGHT JOIN department AS D ON S.dept_id = D.dept_id
GROUP BY D.dept_name
ORDER BY student_number DESC
It looks like you would need to order by both student_number and dept_name
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.