Skip to main content
SQL • LESSON 12

Aggregate Queries

How can we perform multi-metric aggregation and filter groups by averages?

Advanced3 Minutes220 XP
🤔 THE QUESTION

How can we perform multi-metric aggregation and filter groups by averages?

💡 WHAT IS IT?

Combining multiple aggregate metrics with GROUP BY and HAVING produces rich analytical summaries.

🎯 WHAT IS IT USED FOR?

Filtering departments with high average salaries or stores with high average basket sizes.

💻 EXAMPLE
SELECT department,
COUNT(*) AS employee_count,
AVG(salary) AS average_salary
FROM employees
GROUP BY department
HAVING AVG(salary) > 50000;

🎯 Mission Objectives

Practice typing production-grade SQL code for Aggregate Queries.

  • Complex GROUP BY
  • HAVING AVG()
  • Multi-column metrics
  • Executive summaries