employee department wise and count of employees more than 5

后端 未结 3 1048
我在风中等你
我在风中等你 2021-01-29 05:14

i want to display department_id\'s along with count,and count should be more than 5, and i want to have employees who are not hired in January.

i tried the

3条回答
  •  误落风尘
    2021-01-29 05:48

    Select the count from your inner query and join to it:

    SELECT E.*, DEPT_COUNT
    FROM EMPLOYEES E
    JOIN (
       SELECT DEPARTMENT_ID, COUNT(*) DEPT_COUNT
       FROM EMPLOYEES
       GROUP BY DEPARTMENT_ID
       HAVING COUNT(*) > 5 
    ) DC ON E.DEPARTMENT_ID = DC.DEPARTMENT_ID
    AND HIRE_DATE NOT LIKE '%JAN%'
    

提交回复
热议问题