What does HAVING clause mean?
In databases & SQL, HAVING clause means the part of a SQL query that filters groups after GROUP BY has run, usually using the result of an aggregate function such as COUNT or SUM.
Databases & SQL vocabulary · SQL Statements and Queries
In Turkish: HAVING koşulu, grup filtresi
Also used in: Software Engineering
Type at least 2 characters to search all fields.
How it is used
The key rule: WHERE filters rows before grouping, HAVING filters groups after grouping. A typical example is HAVING COUNT(*) > 5. Putting a plain row filter in HAVING works but is slower, so it belongs in WHERE. 'WHERE vs HAVING' is a classic interview question.
Example sentences
Use a HAVING clause to list only the cities with more than 100 customers.
Move the date filter from the HAVING clause to WHERE so fewer rows get grouped.
Common collocations
- HAVING COUNT(*)
- GROUP BY ... HAVING
- filter groups
- WHERE vs HAVING
Related terms
More terms: SQL Statements and Queries
Practise with graded reading
Reading at the right level is the fastest way to make new words stick. Pick free English books by level:
