From the course: Advanced BigQuery
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Aggregating data using ARRAY_AGG - BigQuery Tutorial
From the course: Advanced BigQuery
Aggregating data using ARRAY_AGG
- [Instructor] With the use of the unnest operation, we saw how nested data structures can be flattened in query results. We will now perform the opposite operation and create nested data when running queries. First, though let's add some more data into our customer's table. Here, we add three additional rows. There are two customers who live in Newcastle and one in the city of Portsmouth. The three customers already present in the table live in the city of Liverpool. Let's move ahead and run these insert statements. And three new rows are added to our table. Next, we will execute a query which will perform an aggregation operation based on the table's contents. And this aggregation is based on a nested field, specifically the city in which the customer lives which is extracted from their address. In this query, we group by address.city and then display the city in the select clause. And then the aggregation operation…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.