You are working on a table called orders which contains data for 2021 and you have the second table called orders_archive which contains data for 2020, you need to combine the data from two tables and there could be a possibility of the same rows between both the tables, you are looking to combine the results from both the tables and eliminate the duplicate rows, which of the following SQL statements helps you accomplish this?

You are working on a table called orders which contains data for 2021 and you have the second table called orders_archive which contains data for 2020, you need to combine the data from two tables and there could be a possibility of the same rows between both the tables, you are looking to combine the results from both the tables and eliminate the duplicate rows, which of the following SQL statements helps you accomplish this?
A . SELECT * FROM orders UNION SELECT * FROM orders_archive (Correct)
B. SELECT * FROM orders INTERSECT SELECT * FROM orders_archive
C. SELECT * FROM orders UNION ALL SELECT * FROM orders_archive
D. SELECT * FROM orders_archive MINUS SELECT * FROM orders
E. SELECT distinct * FROM orders JOIN orders_archive on order.id = or-ders_archive.id

Answer: A

Explanation:

Answer is SELECT * FROM orders UNION SELECT * FROM orders_archive UNION and UNION ALL are set operators, UNION combines the output from both queries but also eliminates the duplicates.

UNION ALL combines the output from both queries.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments