Which three Transact-SQL statements should you use?

DRAG DROP
You use Microsoft SQL Server 2012 to develop a database application.
You create a table by using the following definition:
CREATE TABLE Prices (
PriceId int IDENTITY(1,1) PRIMARY KEY,
ActualPrice NUMERIC(16,9),
PredictedPrice NUMERIC(16,9)
)
You need to create a computed column based on a user-defined function named
udf_price_index. You also need to ensure that the column supports an index.
Which three Transact-SQL statements should you use? (To answer, move the appropriate
SQL statements from the list of statements to the answer area and arrange them in the
correct order.)

DRAG DROP
You use Microsoft SQL Server 2012 to develop a database application.
You create a table by using the following definition:
CREATE TABLE Prices (
PriceId int IDENTITY(1,1) PRIMARY KEY,
ActualPrice NUMERIC(16,9),
PredictedPrice NUMERIC(16,9)
)
You need to create a computed column based on a user-defined function named
udf_price_index. You also need to ensure that the column supports an index.
Which three Transact-SQL statements should you use? (To answer, move the appropriate
SQL statements from the list of statements to the answer area and arrange them in the
correct order.)

Answer:

Explanation:



Leave a Reply 14

Your email address will not be published. Required fields are marked *


henry

henry

i think it’s union all. and order is incorrect…

rock

rock

its union all and you for got the division and customer alias

Edouard

Edouard

From the 11 available statements, use : 5 then 8 then 2

Anthony

Anthony

Answer is 5, 6 then 2, as you need to preserve duplicates you will use Union All

Chicco

Chicco

5,6,2 is the right answer

easton

easton

Yes 5, 6 and 2

joe

joe

The proposed solution does’n works: it isn’t possible to create an index on non-precise computed column not persisted. The computed column must be precise or must be presisted.

joe

joe

wops sorry: ignore previous post please. 🙂

jake

jake

no its actually union cause union doesnt give duplicates

jake

jake

oh wait sorry didnt see “retained”

Markos

Markos

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

Kuldip Bhatt

Kuldip Bhatt

Answer is 5 ,6 , 2…. in first select query we have to give alias, union all use to merge table.

Mr Meat

Mr Meat

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.