Skip to main content
SQL โ€ข LESSON 73

HAVING

How can we keep only departments with many employees?

Intermediateโฑ 3 Minutesโญ 860 XP
๐Ÿค” THE QUESTION

How can we keep only departments with many employees?

๐Ÿ’ก WHAT IS IT?

The HAVING clause filters aggregated groups after the GROUP BY operation has executed.

๐ŸŽฏ WHAT IS IT USED FOR?

Filtering high-volume categories, identifying large teams, post-aggregation thresholds.

๐Ÿ’ป EXAMPLE
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department
HAVING COUNT(*) > 10;

๐ŸŽฏ Mission Objectives

Practice typing production-grade SQL code for HAVING.

  • โœ“ HAVING clause
  • โœ“ Post-aggregation filter
  • โœ“ Group thresholding
  • โœ“ HAVING COUNT