Reputation: 43
I have a table called "EMP" and two collumns one called "deptno" and the other called "job". I need a query to find out how many people there are in each type of job within each department.
I know I need to use count() and group by but im not sure how to do this, any help would be appreciated.
Thanks James.
Upvotes: 1
Views: 117
Reputation: 2248
Try This
select job, deptno, count(*) as TotEmp
from emp
group by job, deptno
Upvotes: 0
Reputation: 34387
SELECT JOB, DEPTNO, count(1) AS EMP_COUNT
FROM EMP
GROUP BY JOB, DEPTNO;
Upvotes: 1
Reputation: 204894
select job, deptno, count(*) as people
from emp
group by job, deptno
Upvotes: 2