James
James

Reputation: 43

SQL query using group by

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

Answers (3)

user1819920
user1819920

Reputation: 2248

Try This

select job, deptno, count(*) as TotEmp
from emp
group by job, deptno

Upvotes: 0

Yogendra Singh
Yogendra Singh

Reputation: 34387

  SELECT JOB, DEPTNO, count(1) AS EMP_COUNT
  FROM EMP
  GROUP BY JOB, DEPTNO;

Upvotes: 1

juergen d
juergen d

Reputation: 204894

select job, deptno, count(*) as people
from emp
group by job, deptno

Upvotes: 2

Related Questions