Right join


  • 0
    J
    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
    

  • 0
    C

    @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


Log in to reply
 

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