
Explanation:
The correct answer is SELECT * FROM orders UNION SELECT * FROM orders_archive. The UNION operator combines the results of two queries and removes duplicate rows, whereas UNION ALL includes all rows, including duplicates. INTERSECT and MINUS are not suitable for this scenario as they do not combine all rows from both tables. A JOIN operation is also not appropriate here because it combines rows based on a condition, not simply merging all rows from both tables.
Ultimate access to all questions.
You are tasked with combining data from two tables: orders (2021 data) and orders_archive (2020 data). There might be duplicate rows between them. Which SQL statement will merge the data from both tables while removing duplicates?
A
SELECT * FROM orders INTERSECT SELECT * FROM orders_archive
B
SELECT * FROM orders UNION SELECT * FROM orders_archive
C
SELECT distinct * FROM orders JOIN orders_archive on order.id = orders_archive.id
D
SELECT * FROM orders_archive MINUS SELECT * FROM orders
E
SELECT * FROM orders UNION ALL SELECT * FROM orders_archive
No comments yet.