Questions: SQL: Set Operations (UNION, INTERSECT, EXCEPT)

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A company has two tables: active_customers and archived_customers. Some customers appear in both (reactivated users). You want a complete list of every unique customer. Which query is correct?

ASELECT * FROM active_customers UNION ALL SELECT * FROM archived_customers
BSELECT * FROM active_customers INTERSECT SELECT * FROM archived_customers
CSELECT * FROM active_customers UNION SELECT * FROM archived_customers
DSELECT * FROM active_customers EXCEPT SELECT * FROM archived_customers
Question 2 Multiple Choice

Query A returns customer IDs who ordered in January. Query B returns customer IDs who ordered in February. What does 'A EXCEPT B' return?

ACustomers who ordered in both January and February
BCustomers who ordered in January but not in February
CCustomers who ordered in February but not in January
DAll customers who ordered in either month
Question 3 True / False

UNION MOST generally returns more rows than UNION when applied to the same two queries.

TTrue
FFalse
Question 4 True / False

In a SQL set operation, ORDER BY can be placed inside each individual SELECT statement to control sort order before the rows are combined.

TTrue
FFalse
Question 5 Short Answer

When is it correct to replace UNION with UNION ALL, and what is the benefit?

Think about your answer, then reveal below.