EXISTS tests whether a related record is there and answers true or false, so the outer row is kept exactly once however many matches exist and no subquery column ever reaches your output. This cheatsheet gathers the whole operator on one page, from the correlation that makes it work through SELECT 1, absence tests, boolean flags, nested checks, and the null trap that settles the NOT IN argument, each snippet annotated line by line. Keep it open while you write SQL, or save the image and pin it nearby.
For the full background, read the guide to EXISTS and NOT EXISTS in BigQuery. To practise, work through the 10 code-along examples.
See you soon.
[…] EXISTS and NOT EXISTS in BigQuery Cheatsheet […]
[…] the cheatsheet View the full cheatsheet page PNG · one page · free, no […]