Created
September 30, 2020 01:57
-
-
Save dewaldabrie/8af15a16483b9d544e8ae27289b1eca8 to your computer and use it in GitHub Desktop.
BigQuery CTE Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH basket_1 AS ( | |
| SELECT * | |
| FROM UNNEST([ | |
| STRUCT("apple" AS item_name, 2 AS quantity), | |
| ("banana", 0), | |
| ("pear", 4) | |
| ]) | |
| ), | |
| basket_2 AS ( | |
| SELECT * | |
| FROM UNNEST([ | |
| STRUCT("apple" AS item_name, 3 AS quantity), | |
| ("pear", 1), | |
| ("banana", 5) | |
| ]) | |
| ) | |
| SELECT b1.item_name, b1.quantity as b1_quantity, b2.quantity as b2_quantity | |
| FROM basket_1 b1 | |
| INNER join basket_2 b2 | |
| ON b1.item_name = b2.item_name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment