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;
Questa query restituisce il department_id e poiché raggruppo per department_id, verrà restituito il conteggio dei dipendenti che appartengono a ciascun dipartimento
L'output sarà simile a questo
Department_Id | # of Employees
1 7
2 6
4 9