11 lines
432 B
SQL
11 lines
432 B
SQL
/*Write a query to display the department id and the total salary for those departments which contains at least one salaried
|
|
employee.
|
|
|
|
*/
|
|
|
|
SELECT departments.department_id, result1.total_amt
|
|
FROM departments,
|
|
( SELECT employees.department_id, SUM(employees.salary) total_amt
|
|
FROM employees
|
|
GROUP BY department_id) result1
|
|
WHERE result1.department_id = departments.department_id; |