DRAG DROP
You use Microsoft SQL Server 2012 to develop a database that has two tables named
Div1Cust and Div2Cust.
Each table has columns named DivisionID and CustomerId . None of the rows in Div1Cust
exist in Div2Cust.
You need to write a query that meets the following requirements:
The rows in Div1Cust must be combined with the rows in Div2Cust.
The result set must have columns named Division and Customer.
Duplicates must be retained.
Which three Transact-SQL statements should you use? (To answer, move the appropriate
statements from the list of statements to the answer area and arrange them in the correct order.)

Explanation:
Reference:
http://msdn.microsoft.com/en-us/library/ms180026.aspx
Reference:
http://msdn.microsoft.com/en-us/library/ms188055.aspx
i think it’s union all. and order is incorrect…
0
0
its union all and you for got the division and customer alias
0
0
From the 11 available statements, use : 5 then 8 then 2
0
0
Answer is 5, 6 then 2, as you need to preserve duplicates you will use Union All
0
0
I agree.
0
0
5,6,2 is the right answer
0
0
Yes 5, 6 and 2
0
0
no its actually union cause union doesnt give duplicates
0
0
oh wait sorry didnt see “retained”
0
0
Select DivisionID AS Division
,CustomerID AS Customer
from Div1Cust
UNION ALL
select DivisionID AS division
,CustomerID AS Customer
from Div2Cust
–UNION won’t do it because, we have to retain duplicate
–the other Selects Statements have the word DISTINCT in them which will
–eliminate duplicates. so, the answer should be 5,6,9
1
0
Answer is 5 ,6 , 2…. in first select query we have to give alias, union all use to merge table.
1
0
The answers are 5, 6, and 2.
This question is tricky by design if you notice: ” None of the rows in Div1Cust
exist in Div2Cust.”
Therefore, you could use UNION despite “Duplicates must be retained” because there are no duplicates.
However, UNION ALL performs better than UNION because it lacks SORT which makes it the better choice anyhow.
0
0