Reputation: 21
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
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