A company runs an e-commerce application on Azure SQL Database. The database has a table named Orders with columns: OrderID (int, primary key), CustomerID (int), OrderDate (datetime), TotalAmount (decimal). The application frequently runs the following query: SELECT * FROM Orders WHERE CustomerID = 12345 AND OrderDate BETWEEN '2025-01-01' AND '2025-01-31' ORDER BY OrderDate DESC. The table contains 10 million rows. Which index would best optimize this query?
Answer choices
Why each option matters
Good practice is not just finding the correct option. The wrong answers often show the exact trap the exam wants you to fall into.
Distractor review
A nonclustered index on OrderDate only.
An index on OrderDate alone would help date range scans, but still requires filtering on CustomerID, leading to key lookups or residual predicates. It is not as efficient as a composite index that includes CustomerID.
Best answer
A nonclustered index on (CustomerID, OrderDate DESC) including TotalAmount as included column.
This composite index covers both filter conditions (CustomerID equality, OrderDate range) and includes TotalAmount to avoid key lookups. The descending order helps with ORDER BY OrderDate DESC without additional sorting.
Distractor review
A clustered index on (OrderDate, CustomerID).
A clustered index on these columns would physically reorder the table, which may impact other queries. Also, filtering by CustomerID first (equality) then OrderDate (range) is more efficient when CustomerID is the leading key. This order (OrderDate first) may not be optimal for equality on CustomerID.
Distractor review
A nonclustered index on (OrderDate DESC) only.
Similar to option A, this helps with the order by but does not assist with the CustomerID filter, resulting in inefficient scans.
Common exam trap
Common exam trap: answer the scenario, not the keyword
Many certification questions include familiar terms but test a specific constraint. Read the exact wording before choosing an answer that is generally true but wrong for this case.
Technical deep dive
How to think about this question
This question should be treated as a scenario, not a definition check. Identify the problem, the constraint and the best action. Then compare each option against those facts.
KKey Concepts to Remember
- Read the scenario before looking for a memorised answer.
- Find the constraint that changes the correct option.
- Eliminate answers that are true in general but not in this case.
- Use explanations to understand the rule behind the answer.
TExam Day Tips
- Underline the problem statement mentally.
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Related practice questions
Related DP-900 practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
More questions from this exam
Keep practising from the same exam bank, or move into a focused topic page if this question exposed a weak area.
Question 1
A data engineer needs to process streaming data from IoT devices and store the results in Azure Data Lake Storage for long-term analytics. The data must be processed in near real-time to detect anomalies and trigger alerts. Which Azure service should the engineer use for stream processing?
Question 2
A data engineer needs to query data stored in CSV files in Azure Data Lake Storage Gen2 using T-SQL in Azure Synapse Analytics, without loading the data into the database. Which feature should they use?
Question 3
A data engineer needs to process raw clickstream data from multiple websites that is stored in Azure Blob Storage as JSON files. The processing must run automatically every hour, transform the data into a structured format for reporting, and handle schema changes in the source data without manual intervention. Which Azure service should be used?
Question 4
A data engineer is designing a data lake architecture in Azure. They plan to first ingest raw data from various sources into a landing zone in Azure Data Lake Storage Gen2. Then they will clean, validate, and deduplicate that data in a second zone. Finally, they will create aggregated, business-ready datasets in a third zone for analysts. This layered approach is known as which architecture?
Question 5
A data engineer needs to transform large datasets stored in Azure Data Lake Storage Gen2 using Python and Apache Spark. They want a serverless compute option that automatically scales and requires no cluster management. Which Azure service should they use?
Question 6
A company collects customer feedback forms. Each form contains always-present fields like CustomerID and SubmissionDate, but also a free-text Comments field and optional fields like Rating or ProductCategory that vary between forms. How should this data be classified?
FAQ
Questions learners often ask
What does this DP-900 question test?
Read the scenario before looking for a memorised answer.
What is the correct answer to this question?
The correct answer is: A nonclustered index on (CustomerID, OrderDate DESC) including TotalAmount as included column. — The query filters on both CustomerID and OrderDate, and orders by OrderDate descending. A composite index on (CustomerID, OrderDate) will allow SQL Server to efficiently locate the rows for a specific customer and then scan only the relevant date range. Adding ORDER BY OrderDate DESC can be satisfied by the same index if it is created with descending order on OrderDate or SQL Server can scan the range in reverse. The best index is a nonclustered index on (CustomerID, OrderDate DESC) including all other selected columns (or as a covering index). Option B describes exactly that.
What should I do if I get this DP-900 question wrong?
Then try more questions from the same exam bank and focus on understanding why the wrong options are tempting.
Discussion
Sign in to join the discussion.