EXCEPT has two uses in Query Engine: excluding columns from SELECT *, and subtracting one query’s rows from another’s.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Leave columns out of SELECT *, or remove the rows of one query from another.
EXCEPT has two uses in Query Engine: excluding columns from SELECT *, and subtracting one query’s rows from another’s.
SELECT * EXCEPT (<column> [, ...]) FROM ...
WITH cte AS (SELECT 5 AS c1, 'e6data' AS c2, 10 AS c3)
SELECT * EXCEPT (c3, c2) FROM cte;
| c1 |
|---|
| 5 |
SELECT ...
EXCEPT
SELECT ...
WITH cte AS (
SELECT 1 AS id, 'AAAA' AS name
UNION ALL SELECT 2, 'AAAB'
UNION ALL SELECT 3, 'AAAC'
UNION ALL SELECT 4, 'AAAD'
)
SELECT * FROM cte
EXCEPT
SELECT * FROM cte WHERE id < 3
ORDER BY 1, 2;
| id | name |
|---|---|
| 3 | AAAC |
| 4 | AAAD |