CBSE Class 12 Computer Science Question 84 of 91

Grouping Records, Joins in SQL — Question 19

Back to all questions
19
Question

Question 18

List the count of employees grouped by deptno. (table EMPL)

Answer
SELECT deptno, COUNT(*) AS employee_count
FROM EMPL
GROUP BY deptno;
Output
+--------+----------------+
| deptno | employee_count |
+--------+----------------+
|     20 |              5 |
|     30 |              6 |
|     10 |              3 |
+--------+----------------+