Skip to main content
TutorialApplies to: Unified engine deployments
Combine, deduplicate, and compare two small lists.

Before you start

You need Workbench and a running SQL engine. Every example includes its own input rows. No catalog, files, credentials, or external data is needed. These queries create no stored tables. Copy the SQL into Workbench and run the statements in order. Compare the result with the table below the query. WITH names input data for one statement only. Each example can run on its own.

1. Keep duplicates

What happens when we append both lists?
Expected result UNION ALL keeps every input row. Change one thing: Add Ada to the second list. Expect five rows, including two Adas.

2. Remove duplicates

Who appears in either list?
Expected result UNION removes repeated result rows. Change one thing: Replace UNION with UNION ALL. Ben appears twice.

3. Find common values

Who appears in both lists?
Expected result INTERSECT keeps shared rows. Change one thing: Add Ada to the second list. Expect Ada and Ben.

4. Find removed values

Who appears only in the first list?
Expected result EXCEPT subtracts the right result from the left result. Change one thing: Reverse the inputs. Only Cy remains.

5. Find new values

Who was added in the second list?
Expected result Compare snapshots in the direction of the question. Change one thing: Add Dia to the second list. Expect Cy and Dia.

6. Compare totals

How many distinct people appear overall?
Expected result A set result can be the input to another query. Change one thing: Use UNION ALL. The count becomes 4.

Continue

Continue to Clean text and convert types, or return to Learn Laminar.
Last modified on November 4, 2026