Which Transact-SQL query should you use?

Your database contains a table named Purchases. The table includes a DATETIME column named PurchaseTime that stores the date and time each purchase is

made. There is a non- clustered index on the PurchaseTime column. The business team wants a report that displays the total number of purchases made on the
current day. You need to write a query that will return the correct results in the most efficient manner.
Which Transact-SQL query should you use?

Your database contains a table named Purchases. The table includes a DATETIME column named PurchaseTime that stores the date and time each purchase is

made. There is a non- clustered index on the PurchaseTime column. The business team wants a report that displays the total number of purchases made on the
current day. You need to write a query that will return the correct results in the most efficient manner.
Which Transact-SQL query should you use?

A.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime = CONVERT(DATE, GETDATE())

B.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime = GETDATE()

C.
SELECT COUNT(*)
FROM Purchases
WHERE CONVERT(VARCHAR, PurchaseTime, 112) = CONVERT(VARCHAR, GETDATE(), 112)

D.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime >= CONVERT(DATE, GETDATE())
AND PurchaseTime <DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))

Explanation:
http://technet.microsoft.com/en-us/library/ms181034.aspx



Leave a Reply 5

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


Noel

Noel

are you sure this one for “Provisioning SQL Databases 70-765” for SQL 2016? as everywhere talks about SQL 2012

Noel

Noel

anyone?

J.

J.

It does indeed seem very similar to the SQL 2012. Can’t say for sure, haven’t taken the exam yet.

ena

ena

these are the questions for 70-462: Administering Microsoft SQL Server 2012/2014 Databases.

70-765 is about azure mainly, so most if not all of these questions are not even about the subject matter.

ps: stil props to the guys running this site though, got me through sql 2012/14 with ease 🙂