Hitesh Shetty
Hitesh Shetty

Reputation: 21

How to display deptno, deptname and no of employee?

I am practicing my SQL skills with "EMP" and "Dept" table given in Oracle 11g

I am trying to display department no , department name and no of employees of the department where employee no is greater than 4?

Upvotes: 1

Views: 237

Answers (1)

Mureinik
Mureinik

Reputation: 312257

You can group by the department's details and apply a having condition:

SELECT   d.deptno, d.deptname, COUNT(*)
FROM     dept d
JOIN     emp e ON d.deptno = e.deptno
GROUP BY d.deptno, d.deptname
HAVING   COUNT(*) > 4

Upvotes: 4

Related Questions