🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: GROUP BY and HAVING: all 10 questions

Quiz: GROUP BY and HAVING · Question 8 of 10

Which query finds departments whose average salary is above 60000?

Which query finds departments whose average salary is above 60000?

  1. A.SELECT dept_id FROM employees WHERE AVG(salary) > 60000 GROUP BY dept_id
  2. B.SELECT dept_id FROM employees GROUP BY dept_id WHERE AVG(salary) > 60000
  3. C.SELECT dept_id FROM employees GROUP BY dept_id HAVING AVG(salary) > 60000
  4. D.SELECT dept_id FROM employees HAVING salary > 60000
Answer & explanation

Correct answer: SELECT dept_id FROM employees GROUP BY dept_id HAVING AVG(salary) > 60000

Conditions on aggregates go in HAVING, after GROUP BY.

Can you get the rest right without peeking?

Take the timed Quiz: GROUP BY and HAVING quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →