SQL GROUP BY Multiple Columns
Use GROUP BY column1, column2 to return one result row for each distinct combination of those column values, then apply aggregates such as COUNT(), SUM(), or AVG() to the rows in each combination. The important decision is the result’s grain: decide exactly what one output row represents before writing the query. This guide shows the…
