CBSE Class 12 Computer Science Question 85 of 91

Grouping Records, Joins in SQL — Question 20

Back to all questions
20
Question

Question 19

List the sum of employees' salaries grouped by department. (table EMPL)

Answer
SELECT deptno, SUM(sal) AS total_salary
FROM EMPL
GROUP BY deptno;
Output
+--------+--------------+
| deptno | total_salary |
+--------+--------------+
|     20 |        10885 |
|     30 |         9400 |
|     10 |         8750 |
+--------+--------------+