How come this SQL query doesn't work?
select max(t.salary) as salary from
(SELECT department_id "department Id", SUM(salary) "salary" FROM EMPLOYEES GROUP BY department_id) t;
It shows "salary is invalid identifier " error
CodePudding user response:
SELECT SUM(salary) AS salary
FROM EMPLOYEES
GROUP BY department_id
ORDER BY salary DESC LIMIT 1;
CodePudding user response:
select max(t.salary) as salary
from(
SELECT department_id AS `department Id`, SUM(salary) AS `salary`
FROM EMPLOYEES
GROUP BY department_id
) AS t