SQL 2023 · Aggregation and window functions

Filter groups

Keep only groups that meet a condition. WHERE filters rows before grouping, HAVING filters groups after.

SELECT user_id, COUNT(*) FROM orders GROUP BY user_id HAVING COUNT(*) > 5;

Official SQL 2023 documentation

More aggregation and window functions commands

All aggregation and window functions commands · SQL 2023 cheatsheet

Was this page helpful?