AI engineering glossary · SQL databases

What is HAVING?

HAVING: A clause that filters groups after aggregation, using conditions on aggregate results. WHERE cannot do this because it runs before grouping. Use WHERE for row filters and HAVING for group filters.

Level: beginnerTopic: SQL databases

HAVING: an example

GROUP BY city HAVING COUNT(*) > 100 keeps only cities with more than 100 customers.

Related terms

More SQL databases terms

Where you learn it

HAVING is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.