
Explanation:
The correct answer is SELECT * FROM CUSTOMERS_2021 INTERSECT SELECT * FROM CUSTOMERS_2020. The INTERSECT operation is designed to return the set of rows that are common to both subqueries, making it the ideal choice for identifying rows that match across all columns in both tables. Unlike an INNER JOIN, which checks for matches based on a single column, INTERSECT compares all columns. The UNION and UNION ALL operations combine rows from both tables but do not identify matches. The EXCEPT operation returns rows from the first query that are not in the second query, which is not what we need in this scenario.
Ultimate access to all questions.
Your marketing team has requested your help to identify customers with identical information across two tables, CUSTOMERS_2021 and CUSTOMERS_2020. Both tables share the same schema with 25 columns each. Which SQL operation would you use to find rows that match across all columns in both tables?
A
SELECT * FROM CUSTOMERS_2021 UNION SELECT * FROM CUSTOMERS_2020
B
SELECT * FROM CUSTOMERS_2021 UNION ALL SELECT * FROM CUSTOMERS_2020
C
SELECT * FROM CUSTOMERS_2021 C1 INNER JOIN CUSTOMERS_2020 C2 ON C1.CUSTOMER_ID = C2.CUSTOMER_ID
D
SELECT * FROM CUSTOMERS_2021 INTERSECT SELECT * FROM CUSTOMERS_2020
E
SELECT * FROM CUSTOMERS_2021 EXCEPT SELECT * FROM CUSTOMERS_2020
No comments yet.