Skip to main content
SQL โ€ข LESSON 76

WHERE + GROUP BY + HAVING

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

Intermediateโฑ 3 Minutesโญ 890 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