Skip to Content
Learning Google BigQuery
book

Learning Google BigQuery

by Thirukkumaran Haridass, Eric Brown
December 2017
Beginner to intermediate
264 pages
5h 38m
English
Packt Publishing
Content preview from Learning Google BigQuery

ROLLUP

The ROLLUP function is used to perform aggregation at multiple levels. The following query returns the number of trips made per month by the company specified in the where clause, and it also shows the total trips for each year and the total trips made in all the years available:

#legacySQLSELECT STRFTIME_UTC_USEC(trip_start_timestamp,'%Y') as trip_year,STRFTIME_UTC_USEC(trip_start_timestamp,'%Y-%m') as trip_year_month,company,count(1) as trip_countFROM [bigquery-public-data:chicago_taxi_trips.taxi_trips] WHERE company = '1085 - N and W Cab Co'GROUP BY ROLLUP(company, trip_year, trip_year_month)order by company, trip_year, trip_year_month
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Google BigQuery: The Definitive Guide

Google BigQuery: The Definitive Guide

Valliappa Lakshmanan, Jordan Tigani
Google BigQuery Analytics

Google BigQuery Analytics

Siddartha Naidu, Jordan Tigani

Publisher Resources

ISBN: 9781787288591Supplemental Content