Count Student Number in Departments


  • 0

    Click here to see the full article post


  • 0
    D

    Why not using inner join instead of outer join

    SELECT
    dept_name, COUNT(*) AS student_number
    FROM
    department
    inner JOIN
    student ON department.dept_id = student.dept_id
    GROUP BY department.dept_name
    ORDER BY student_number DESC , department.dept_name
    ;


  • 0

    Because the 'inner join' will miss the departments with no current students.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.