Open this example in the interactive library
Source code
WITH a(n) AS (VALUES (1),(2)),b(n) AS (VALUES (2),(3)),both_sets AS (SELECT n FROM a UNION ALL SELECT n FROM b) SELECT n FROM both_sets GROUP BY n HAVING count(*)=1;
Sample output
[
{
"n": 1
},
{
"n": 3
}
]