Your database contains two tables named DomesticSalesOrders and InternationalSalesOrders. Both
tables contain more than 100 million rows. Each table has a Primary Key column named
SalesOrderId. The data in the two tables is distinct from one another.
Business users want a report that includes aggregate information about the total number of global
sales and total sales amounts.
You need to ensure that your query executes in the minimum possible time.
Which query should you use?

A.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM (
SELECT SalesOrderId, SalesAmount
FROM DomesticSalesOrders
UNION ALL
SELECT SalesOrderId, SalesAmount
FROM InternationalSalesOrders
) AS p
B.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM (
SELECT SalesOrderId, SalesAmount
FROM DomesticSalesOrders
UNION
SELECT SalesOrderId, SalesAmount
FROM InternationalSalesOrders
) AS p
C.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM DomesticSalesOrders
UNION
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM InternationalSalesOrders
D.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM DomesticSalesOrders
UNION ALL
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM InternationalSalesOrders
Explanation:
http://msdn.microsoft.com/en-us/library/ms180026.aspx
http://blog.sqlauthority.com/2009/03/11/sql-server-difference-between-union-vs-unionall-optimalperformance-comparison/
A
0
0
A.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM (
SELECT SalesOrderId, SalesAmount
FROM DomesticSalesOrders
UNION ALL
SELECT SalesOrderId, SalesAmount
FROM InternationalSalesOrders
) AS p
UNION ALL – A UNION statement effectively does a SELECT DISTINCT on the results set. If you know that all the records returned are unique from your union, use UNION ALL instead, it gives faster results.
0
0
?
a
0
0
The time to read or take a look at the subject material or web pages we have linked to below.
0
0
Please visit the web pages we follow, which includes this one, as it represents our picks in the web.
0
0
just beneath, are several absolutely not related web-sites to ours, even so, they may be surely worth going over
0
0
Sites of interest we have a link to.
0
0
The information talked about inside the post are some of the most beneficial accessible
0
0
The facts talked about inside the report are a number of the most beneficial accessible
0
0
Please stop by the web-sites we stick to, including this a single, as it represents our picks in the web.
0
0
Here is a superb Blog You might Come across Fascinating that we encourage you to visit.
0
0
Every once in a whilst we select blogs that we read. Listed beneath would be the latest web pages that we pick
0
0
always a big fan of linking to bloggers that I love but really don’t get a lot of link love from
0
0
please stop by the web sites we stick to, such as this 1, because it represents our picks through the web
0
0
The data mentioned inside the report are a number of the most effective available
0
0
Wonderful story, reckoned we could combine a few unrelated data, nonetheless truly worth taking a search, whoa did a single understand about Mid East has got a lot more problerms at the same time
0
0
By the way, part of the new 200Q 70-461 dumps are available here:
https://drive.google.com/open?id=0B-ob6L_QjGLpfnJldlZxTklTaHM0akpJUzhja2pETHJOS0owMzd4eVk1UTVNQUpvdlVxVWM
Best Regards!
0
0