SQL Database Set Operation Principles Quiz
A 50-question quiz exploring UNION, UNION ALL, INTERSECT, and EXCEPT with practical patterns, duplicates, ordering, and dataset comparison.
Question 1
A reporting tool needs to combine two lists of active users—one from a subscription table and one from a trial table. Both contain some overlapping users. Which set operation removes duplicates so each user appears only once in the final result?
Question 2
A system merges two sources of product IDs from old and new systems. Since both systems may record the same product multiple times, the team needs an operation that preserves all duplicates while combining the lists. Which operation suits this?
Question 3
An analyst wants to find customers who appear in both a newsletter signup list and a recent purchases list. Which operation isolates values present in both datasets?
Question 4
A cleanup task needs to identify email addresses in an old marketing list that do not appear in a newly validated list. Which operation isolates values from the first set that don’t appear in the second?
Question 5
Two branch offices maintain their own lists of customer IDs. To build a master view of all unique customers, which operation merges the lists while eliminating repeated IDs?
Question 6
Why must the queries used in a UNION return the same number of columns?
Question 7
Two datasets compare product codes, where one dataset contains text values and the other numeric values. Why might the set operation fail without casting?
Question 8
A quality audit checks for overlapping employee IDs reported by two different HR systems. Which set operation directly answers whether an ID appears in both lists?
Question 9
A data migration compares new records to old ones. Which operation isolates only the newly added IDs that don’t appear in the legacy dataset?
Question 10
Someone attempts to apply ORDER BY to the first query inside a UNION, but the result ordering looks unexpected. Why?
Question 11
A team compares city lists from two travel apps. They discover that NULL appears in their INTERSECT results only under specific conditions. What explains this behavior?
Question 12
During a list cleanup, someone uses UNION ALL and notices repeated email addresses. Why does this happen even though both lists were meant to be unique?
Question 13
A teacher compares two attendance lists to identify students missing from the second list. Which logic correctly describes what EXCEPT accomplishes?
Question 14
A manager wants to compare employees in North and East divisions to see who belongs to both. Why is INTERSECT the appropriate choice?
Question 15
Two queries with different column counts are passed to a UNION operation and the system raises an error. What fundamental rule is being violated?
Question 16
A data warehouse identifies values that only appear in the backup dataset. Which operation, reversed from the typical pattern, reveals extra values in the second query?
Question 17
If both lists contain overlapping values and the goal is to count how many duplicate entries exist across both lists combined, why is UNION ALL preferred over UNION?
Question 18
A reporting engine treats set operations as mathematical sets. What common behavior does UNION share with mathematical set union?
Question 19
A researcher wants to confirm that two independent surveys captured some of the same respondents. Which set operation will show the overlapping survey IDs?
Question 20
If a user mistakenly applies EXCEPT reversed (dataset B EXCEPT dataset A), what is fundamentally being extracted?
Question 21
A cleanup task uses INTERSECT but notices some entries missing from the result because one of the queries applies a filter. Why does filtering affect the intersection?
Question 22
When merging two lists using UNION ALL for reporting, why might the final count be misleading without deduplication?
Question 23
A team comparing data quality uses EXCEPT to detect values missing from the second dataset, but they notice ordering differences do not matter. Why?
Question 24
Why does EXCEPT consider NULL values equal when comparing two queries?
Question 25
A query uses UNION to merge two sets but unexpectedly loses some rows because duplicates were removed. Why is this expected?
Question 26
This query merges customer IDs from two regions. What will the result look like regarding duplicates?
SELECT id FROM region_a
UNION
SELECT id FROM region_b;Question 27
How does this UNION ALL behave when merging product codes from two supplier feeds?
SELECT code FROM supplier_x
UNION ALL
SELECT code FROM supplier_y;Question 28
What does this INTERSECT operation identify between two login history tables?
SELECT user_id FROM logins_week1
INTERSECT
SELECT user_id FROM logins_week2;Question 29
The following EXCEPT statement compares dataset A against dataset B. What appears in the result?
SELECT email FROM list_a
EXCEPT
SELECT email FROM list_b;Question 30
Why does this UNION fail unless both subqueries return the same number of columns?
SELECT name, city FROM contacts
UNION
SELECT name FROM archive;Question 31
This UNION merges two tables of categories. How are NULL values handled?
SELECT category FROM set1
UNION
SELECT category FROM set2;Question 32
How does INTERSECT behave with NULLs in this comparison?
SELECT value FROM a
INTERSECT
SELECT value FROM b;Question 33
This EXCEPT operation finds discontinued products. What does it return?
SELECT name FROM all_products
EXCEPT
SELECT name FROM currently_active;Question 34
What effect does ORDER BY have here?
SELECT id FROM a
UNION
SELECT id FROM b
ORDER BY id;Question 35
This pair of sets compares regions. What appears in the output of INTERSECT?
SELECT region FROM r1
INTERSECT
SELECT region FROM r2;Question 36
Why does this UNION ALL help track duplicate purchases?
SELECT user_id FROM purchases_jan
UNION ALL
SELECT user_id FROM purchases_jan;Question 37
This EXCEPT operation checks for missing mapping records. What scenario does it detect?
SELECT code FROM expected_items
EXCEPT
SELECT code FROM actual_items;Question 38
What does this simple UNION achieve between two attribute lists?
SELECT attr FROM a
UNION
SELECT attr FROM b;Question 39
Why does this INTERSECT query help validate matching manager IDs?
SELECT manager_id FROM system1
INTERSECT
SELECT manager_id FROM system2;Question 40
This UNION ALL merges two survey responses. What characteristic defines the output?
SELECT response FROM survey_a
UNION ALL
SELECT response FROM survey_b;Question 41
This expression checks for discontinued categories. What does it reveal?
SELECT category FROM previous_year
EXCEPT
SELECT category FROM current_year;Question 42
This INTERSECT query checks which device IDs appear in both logs. What does it identify?
SELECT device_id FROM log1
INTERSECT
SELECT device_id FROM log2;Question 43
Why does this combined query show unique customer names?
SELECT name FROM new_signups
UNION
SELECT name FROM returning_users;Question 44
What happens when these queries with different numeric types are combined via UNION after casting?
SELECT CAST(price AS DECIMAL(10,2)) FROM a
UNION
SELECT CAST(amount AS DECIMAL(10,2)) FROM b;Question 45
This EXCEPT operation checks which IDs did not move forward to the next phase. What does it find?
SELECT id FROM phase1
EXCEPT
SELECT id FROM phase2;Question 46
This UNION ALL merges color codes from two palettes. Why might designers use UNION ALL instead of UNION?
SELECT color FROM palette1
UNION ALL
SELECT color FROM palette2;Question 47
How does INTERSECT help validate that two inventory systems register the same SKUs?
SELECT sku FROM inv1
INTERSECT
SELECT sku FROM inv2;Question 48
This EXCEPT operation checks for invalid category assignments. What does the result represent?
SELECT category FROM assignments
EXCEPT
SELECT category FROM valid_categories;Question 49
This UNION merges two mailing lists. What does the final output guarantee?
SELECT email FROM list1
UNION
SELECT email FROM list2;Question 50
This INTERSECT detects customers appearing in both segments. What insight does this provide?
SELECT customer_id FROM segment_a
INTERSECT
SELECT customer_id FROM segment_b;