Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 633 Bytes

File metadata and controls

32 lines (23 loc) · 633 Bytes

English Version

题目描述

None

解法

SQL

SELECT dept_name,
        ifnull(total,
        0) AS student_number
FROM department
LEFT JOIN 
    (SELECT dept_id,
         count(*) AS total
    FROM student
    GROUP BY  dept_id) tmp
    ON department.dept_id = tmp.dept_id
ORDER BY  tmp.total desc