>- see footer for list info -<
SELECT d.name, count(d.name) AS [EmpNum]
FROM DEPARTMENTS d
INNER JOIN EMPLOYEES e
ON d. uid = e.department_ID
GROUP BY d.name

Simon Baynes
www.simonbaynes.com
Free online storage you can access anywhere:-
http://www.simonbaynes.com/getsugarsync
LinkedIn profile:- http://www.linkedin.com/in/simonbaynes



On Thu, Mar 18, 2010 at 12:06 PM, Damien Gallagher <[email protected]> wrote:
>>- see footer for list info -<
> Hi guys,
>
> I have one table called DEPARTMENTS (uid,name) and one called
> EMPLOYEES(uid,emp_name,department_ID).
>
> The EMPLOYEES table contains department_id  so we know which
> department the employee belongs to.
>
> How do I write a SQL query to get all department names, but include in
> that resultset the number of employees within each deartment. So for
> exampe:
>
> 1. Housing (4 Employees)
> 2. Catering (10 Employees)
> 3. Drinks (2 Employees)
>
> Etc...
>
> thanks, Damien
>
> _______________________________________________
>
> For details on ALL mailing lists and for joining or leaving lists, go to 
> http://list.cfdeveloper.co.uk/mailman/listinfo
>
> --
> CFDeveloper Sponsors:-
>>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>>- Lists hosted by www.Gradwell.com -<
>>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<
>

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- cfdeveloper Hosting provided by www.cfmxhosting.co.uk -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to