Using GROUP BY ALL in BigQuery

Featured in other database systems, the GROUP BY ALL has been announced in preview for BigQuery as well.

This will allow us to not enumerate all the non-aggregated columns when performing aggregates.

It's definitely better than GROUP BY 1,2,3 which would fail once we'd change the list of columns we'd like to group by. Overall, I find it a useful shorthand when exploring or debugging.

Here's an example of how it looks.


SELECT country, sell_date, SUM(sales) AS total_sales

FROM input_data

-- new
GROUP BY ALL

-- instead of
-- GROUP BY country, sell_date

Found it useful? Check out to my Analytics newsletter at notjustsql.com.