Skip to content
Advertisement

basic sql employee

The employee table (EMP) specifies groups by department code, the sum of salaries by group, the average (constant treatment), and the number of people in each group’s salary, and is presented below, listed in department code order. I would like to modify the following SQL syntax to look up departments whose average salary exceeds 2800000.

 SELECT
    DEPT
    , SUM(SALARY) 합계
    , FLOOR(AVG(SALARY)) 평균
    , COUNT(*) 인원수
    FROM
    EMP
    GROUP BY
    DEPT
    ORDER BY DEPT ASC;

question 1. Conditions that need to be modified

question 2. What should I add to the presented code?

Advertisement

Answer

you can use below sql:

SELECT
    DEPT
    , SUM(SALARY) 합계
    , FLOOR(AVG(SALARY)) 평균
    , COUNT(*) 인원수
    FROM
    EMP
    GROUP BY
    DEPT having FLOOR(AVG(SALARY) > 2800000
    ORDER BY DEPT ASC;
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement