From the course: Advanced BigQuery

Unlock this course with a free trial

Join today to access over 24,500 courses taught by industry experts.

Querying nested data

Querying nested data - BigQuery Tutorial

From the course: Advanced BigQuery

Querying nested data

- [Instructor] It's time to query our customers table and access specific fields within unnested content. We start off by running this SELECT query. On line number one, we have the firstname and lastname, which we reference as we have all other fields so far, and then we access the individual fields within the address records. To access the city, we can make use of the dot notation, address.city and similarly, we use address.county to retrieve the county values. The phonenumbers field, of course, is an array and to access specific element based on its index, we will need to make use of the OFFSET function. We cannot just use numbers directly. Here it is the first phonenumber that at index zero which will be returned for each customer. We will also set an alias of primaryphone in the query results. When this is executed, you'll see that the results contain no nested data. Each of the fields in the SELECT clause appears…

Contents