Avatar of Rob Rudloff
Rob Rudloff
Flag for United States of America

asked on 

SQL Select with count() from another table?

Hi.
I'd like to select * from an Department table and also include a column that is a count() of Employees in each Department.    The Department table (simplified) includes a unique Dept_ID and Description.  Each Employee in the [Emp] table has a "Dept_ID" column, indicating which department the employee is in.

So, in the end, I'd like a resultset something like:

Dept_ID   Description     Emp_Count
-------   -------------   ---------
1         Dept 1 A/P             12
2         Dept 2 Office           8
3         Dept 3 A/R             11

Open in new window


 Is that possible?  I was trying to use a "select" statement in a join, but am doing something wrong ...
-- Thanks
Microsoft SQL Server 2008Microsoft SQL Server

Avatar of undefined
Last Comment
PortletPaul

8/22/2022 - Mon