What is the difference between WHERE and HAVING in SQL?

SQL Fundamentals Medium

SQL Fundamentals — Medium

What is the difference between WHERE and HAVING in SQL?

Key points

  • WHERE filters rows before grouping; HAVING filters groups after aggregation
  • WHERE is used with individual rows; HAVING is used with grouped data
  • Understanding this distinction is essential for writing efficient SQL queries

Ready to go further?

Related questions