Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paslandau/662a42456dc9dc77b6cbdb1d6acb8c99 to your computer and use it in GitHub Desktop.
Save paslandau/662a42456dc9dc77b6cbdb1d6acb8c99 to your computer and use it in GitHub Desktop.
Using temporary tables via WITH (named subqueries) in Google BigQuery
-- Using temporary tables via WITH (named subqueries) in Google BigQuery; 2020-05-29
-- @see http://www.pascallandau.com/bigquery-snippets/use-temporary-tables-with-named-subquery/
WITH data as (
SELECT
1 as id,
DATE("2018-04-08") AS date,
UNION ALL SELECT 2, DATE("2018-04-09")
UNION ALL SELECT 3, DATE("2018-04-10")
UNION ALL SELECT 4, DATE("2018-04-11")
),
filtered_data as (
SELECT
id
FROM
data
WHERE
id BETWEEN 2 and 3
)
SELECT
*
FROM
filtered_data
@paslandau
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment