Your database contains a table named SalesOrders. The table includes a DATETIME
column named OrderTime that stores the date and time each order is placed. There is a
non-clustered index on the OrderTime column.
The business team wants a report that displays the total number of orders placed 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 SalesOrders
WHERE OrderTime = CONVERT(DATE, GETDATE())
B.
SELECT COUNT(*) FROM SalesOrders
WHERE OrderTime = GETDATE()
C.
SELECT COUNT(*) FROM SalesOrders
WHERE CONVERT(VARCHAR, OrderTime, 112) = CONVERT(VARCHAR, GETDATE(I,
112))
D.
SELECT COUNT(*) FROM SalesOrders
WHERE OrderTime >= CONVERT(DATE, GETDATE())
AND OrderTime < DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))
C is correct
Compare date in format yyyymmdd
http://www.sqlusa.com/bestpractices2005/centurydateformat/
0
0
Answer C will not use index. D is correct answer
0
0
D is the correct answer.
0
0
D is the most efficient.
0
0
Besides, SOME new 200Q 70-461 dumps are available here:
https://drive.google.com/open?id=0B-ob6L_QjGLpfnJldlZxTklTaHM0akpJUzhja2pETHJOS0owMzd4eVk1UTVNQUpvdlVxVWM
Best Regards!
0
0