64. Items on Exactly One Menu (Symmetric Difference)
HardSet Operationssymmetric differenceEXCEPTUNIONORDER BY
The symmetric difference of two sets is everything in exactly one of them — (A EXCEPT B) UNION (B EXCEPT A). It combines two set-difference operations with a final UNION, then a single ORDER BY.
Task: two cafe locations each have a menu. Return the items that appear on exactly one menu (present at one location but not the other), tagging which side it came from.
Return columns item, only_at. Order by item ascending.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.