When writing queries in SQL, we sometimes need to summarize data based on specific criteria. Fortunately SQL makes this easy to achieve with the GROUP BY
and HAVING
clauses. These two clauses allow us to aggregate data and filter the results based on group conditions.
More specifically, GROUP BY
allows us to group the results, and HAVING
is an optional clause that we can use to filter the results based on certain conditions.
Below is an example of where we can use these two clauses to aggregate data and filter it based on certain criteria.
Continue reading