Skip to main content
SQL • LESSON 76

WHERE + GROUP BY + HAVING

How can we find active departments with more than ten employees?

Intermediate3 Minutes890 XP
🤔 THE QUESTION

How can we find active departments with more than ten employees?

💡 WHAT IS IT?

The complete aggregation pipeline filters rows with WHERE, groups them with GROUP BY, and filters groups with HAVING.

🎯 WHAT IS IT USED FOR?

Complex business reports, active team sizing, robust data analytics workflows.

💻 EXAMPLE
SELECT department, COUNT(*) AS active_employees
FROM employees
WHERE status = 'Active'
GROUP BY department
HAVING COUNT(*) > 10;

🎯 Mission Objectives

Practice typing production-grade SQL code for WHERE + GROUP BY + HAVING.

  • WHERE + GROUP BY + HAVING
  • Complete aggregation pipeline
  • Strict business rules
  • Data engineering standards