Home›Learn›SQL›HAVING
SQL Master CourseBeginner Friendly

HAVING

Learn how to filter grouped results.

📘 Chapter 26 / 51⏱️ 8–10 Min Read🎯 Beginner Friendly
Course Progress51%

Course Progress

51%

26 / 51 chapters

📖

Theory

Understand the concept step by step

HAVING filters groups after GROUP BY has been applied. WHERE generally filters individual rows before grouping, while HAVING filters groups produced by aggregation.
💻

Example

See how the concept works in SQL

SQL
SELECT department, COUNT(*) AS employees
FROM employees
GROUP BY department
HAVING COUNT(*) > 5;
📤

Output

Understand what the query produces

Only departments with more than five employees are returned.

📝

Practice

Test your understanding

Find categories containing more than ten products.

❓

MCQs

Check your SQL knowledge

What is the main concept covered in HAVING?

A.Filters groups
B.Creates groups
C.Deletes groups
D.Sorts groups
💼

Interview Questions

Prepare for SQL interviews

1

Interview Question

What is HAVING used for?

2

Interview Question

What is the difference between WHERE and HAVING?

3

Interview Question

Can HAVING be used with aggregate functions?