- see footer for list info -<
thanks!

Simon Baynes wrote:
- 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 -<

--
Betenoir Web Creative <http://betenoir.net/>      Damien Gallagher, Director
betenoir.net <http://www.betenoir.net>

[email protected] <mailto:[email protected]>
+44 (0)20 7630 7772
+44 (0)78 1204 3315     *NEW!*
Check out our new site:
betenoir.net <http://betenoir.net>

Tell us what you think...
Twitter <http://www.twitter.com/betenoir_ltd> Follow us on twitter, twitter.com/betenoir_ltd <http://www.twitter.com/betenoir_ltd>
Blog <http://www.betty-noir.net> Subscribe to our blog, betty-noir.net

<http://www.betty-noir.net>
* CONTENT, COMMUNICATION AND CREATIVITY ON THE WEB*


_______________________________________________

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