First page Back Continue Last page Image

Adding GROUP BY and HAVING to our Queries

SELECT select_list

FROM table_source

[WHERE search_condition]

[GROUP BY group_by_list]

[HAVING search_condition]

[ORDER BY order_by_list]

This is the basic syntax for using GROUP BY, HAVING and ORDER BY

The [ ] brackets mean that the clause is optional, so you can use these options one at a time or all at the same time

GROUP BY allows us to break large chunks of data into smaller chunks for easier processing (It is also called Data Reduction)