What does the following query do? SELECT dept_id, AVG(salary) FROM employees GROUP BY dept_id HAVING AVG(salary) > 60000

SQL Fundamentals Medium

SQL Fundamentals — Medium

What does the following query do? SELECT dept_id, AVG(salary) FROM employees GROUP BY dept_id HAVING AVG(salary) > 60000

Key points

  • The query uses the AVG() function to calculate average salary per department.
  • The HAVING clause filters results based on the calculated average salary.
  • GROUP BY groups results by department ID.

Ready to go further?

Related questions