SELECT department_ID, count(employee_id) as '# of Employees' FROM EMPLOYEES
WHERE DEPARTMENT_ID IN
(
SELECT DEPARTMENT_ID
FROM EMPLOYEES
GROUP BY DEPARTMENT_ID
HAVING COUNT(*)>5
)
AND HIRE_DATE NOT LIKE '%JAN%'
group by department_ID;
Esta consulta retorna o department_id e por eu agrupar por department_id, será retornada a contagem de funcionários que pertencem a cada departamento
A saída será algo assim
Department_Id | # of Employees
1 7
2 6
4 9