70-457 · Question #20
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…
The correct answer is D. SELECT COUNT(*). Two answers will return the correct results (the "WHERE CONVERT..." and "WHERE ... AND ... " answers). The correct answer for Microsoft would be the answer that is most "efficient". Anybody have a clue as to which is most efficient? In the execution plan, the one that I've…
Question
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?
Options
- ASELECT COUNT(*)
- BSELECT COUNT(*)
- CSELECT COUNT(*)
- DSELECT COUNT(*)
How the community answered
(60 responses)- A7% (4)
- B3% (2)
- C12% (7)
- D78% (47)
Explanation
Two answers will return the correct results (the "WHERE CONVERT..." and "WHERE ... AND ... " answers). The correct answer for Microsoft would be the answer that is most "efficient". Anybody have a clue as to which is most efficient? In the execution plan, the one that I've selected as the correct answer is the query with the shortest duration. Also, the query answer with "WHERE CONVERT..." threw warnings in the execution plan... something about affecting CardinalityEstimate and SeekPlan.
Topics
Community Discussion
No community discussion yet for this question.