CBSE Class 12 Computer Science Question 81 of 91

Grouping Records, Joins in SQL — Question 16

Back to all questions
16
Question

Question 15

Show the average salary for all departments with more than 3 people for a job.

Answer
SELECT job, AVG(Sal) AS AvgSalary 
FROM Empl 
GROUP BY job HAVING COUNT(*) > 3;
Output
+----------+-----------+
| job      | AvgSalary |
+----------+-----------+
| CLERK    |    1037.5 |
| SALESMAN |      1400 |
+----------+-----------+