← 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?
- A.SELECT dept_id FROM employees WHERE AVG(salary) > 60000 GROUP BY dept_id
- B.SELECT dept_id FROM employees GROUP BY dept_id WHERE AVG(salary) > 60000
- C.SELECT dept_id FROM employees GROUP BY dept_id HAVING AVG(salary) > 60000
- 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 →