A data analyst is tasked with creating a comprehensive sales report for the first half of the year. The data is stored in two separate tables: Sales_Q1 and Sales_Q2. Both tables have the exact same structure and columns: TransactionID, ProductID, SaleDate, and Amount. The analyst needs to combine all rows from both tables into a single dataset. The final dataset must not contain any duplicate transaction rows.
Which SQL clause should the analyst use to accomplish this?
The correct answer is UNION. The UNION operator is used to combine the result sets of two or more SELECT statements. By default, UNION removes duplicate rows from the final result set, which meets the specific requirement of the scenario.
UNION ALL is incorrect because, while it also combines result sets, it includes all rows, including duplicates. The scenario explicitly states that duplicate rows must not be in the final dataset.
INNER JOIN is incorrect because it combines tables horizontally based on a matching condition in specified columns. It is used to add columns from another table, not to stack rows from tables with identical structures.
APPEND is incorrect because it is not a standard SQL set operator for combining result sets. While the concept is 'appending', the correct SQL keyword is UNION or UNION ALL.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the primary difference between UNION and UNION ALL in SQL?
Open an interactive chat with Bash
When would it be better to use UNION ALL instead of UNION?
Open an interactive chat with Bash
Why is INNER JOIN not suitable for combining rows in this scenario?
Open an interactive chat with Bash
CompTIA Data+ DA0-002 (V2)
Data Acquisition and Preparation
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .