Skip to content

Instantly share code, notes, and snippets.

@rich
Forked from tmilewski/gist:132033
Created June 18, 2009 17:51
Show Gist options
  • Save rich/132043 to your computer and use it in GitHub Desktop.
Save rich/132043 to your computer and use it in GitHub Desktop.
select
d.id,
coalesce(f.cnt, 0) as cnt
from
departments as d left join
(select department_primary, count(1) as cnt from faculty group by department_primary) as f
on f.department_primary = d.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment