why counting distinct student is wrong?

  • 0

    My code below is almost the same as the editorial solution except that I used count(distinct student_name). I think duplicate students should not be counted.

    select d.dept_name, count(distinct s.student_name) as student_number from department d
    left join student s on d.dept_id=s.dept_id
    group by d.dept_name 
    order by student_number desc, d.dept_name

  • 0

    why not count student id? There may be duplicated names in fact.

Log in to reply

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