Last active
April 15, 2023 03:49
-
-
Save benjaminestes/5846a4da1f68621b607e98f23053de43 to your computer and use it in GitHub Desktop.
Semidifference or semijoin operations in BigQuery
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
| #standardSQL | |
| WITH | |
| a AS ( | |
| SELECT | |
| num | |
| FROM | |
| UNNEST(GENERATE_ARRAY(1, 6)) AS num), | |
| b AS ( | |
| SELECT | |
| num | |
| FROM | |
| UNNEST(GENERATE_ARRAY(3, 8)) AS num) | |
| SELECT | |
| DISTINCT num | |
| FROM | |
| a WHERE | |
| -- Or 'IN' for semijoin | |
| (num) NOT IN ( | |
| SELECT | |
| num | |
| FROM | |
| b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment