Subqueries in BigQuery SQL

Pulling values from GA4 Event Paramaters

A subquery is a query that appears inside another SQL query statement. Subqueries are also referred to as sub-SELECTs or nested SELECTS.

There are various types of subqueries and I will introduce them as required in future posts.

One of the most common subqueries that you will use for GA4 data in BigQuery is called Expression Suqquery.

Expression Subquery is used in SQL expressions and returns only a single value.

There are different types of Expression subqueries and again, I will also introduce them as required.

In this post, I will show you Scalar subquery, a type of Expression subquery that helps you use the event paramater values that are stored in the nested column.

To understand a subquery and scalar subquery let’s take a look at an example.

SELECT event_name, 
(SELECT value.string_value from unnest(event_params) WHERE key = 'page_location') as page_location
FROM `your-project.your-dataset.events_######`

This query has two values in the SELECT list:

Subscribe to keep reading

This content is free, but you must be subscribed to GA4 BigQuery Newsletter For Marketing Analytics to continue reading.

Already a subscriber?Sign In.Not now

Reply

or to participate.