DA0-002 Data Acquisition and Preparation Practice Question
An analyst needs to compute a running total of sales for each department, ordered by date. Which window function is most appropriate?
⚠ Common exam trap
DA0-002 often tests the omission of PARTITION BY in window functions, causing candidates to compute a running total across all departments instead of per department.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
SUM(sales) OVER (PARTITION BY department ORDER BY date)
The running total of sales for each department, ordered by date, requires a window function that sums sales over a partition by department and orders by date. SUM(sales) OVER (PARTITION BY department ORDER BY date) computes a cumulative sum within each department as the date progresses, which is exactly a running total.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
ROW_NUMBER() OVER (PARTITION BY department ORDER BY date)
Why it's wrong here
ROW_NUMBER assigns a sequential integer to each row within the department partition, so it labels positions rather than accumulating sales values. It is tempting because it shares the PARTITION BY department ORDER BY date clause, and it would be correct for ranking rows, deduplicating records, or selecting the latest row per department.
- ✗
SUM(sales) OVER (ORDER BY date)
Why it's wrong here
Omitting PARTITION BY department makes the window span the entire result set, so the running total crosses department boundaries instead of restarting per department. It is tempting because it correctly uses SUM with ORDER BY date to accumulate, and it would be right for a company-wide running total ignoring department grouping.
- ✓
SUM(sales) OVER (PARTITION BY department ORDER BY date)
Why this is correct
SUM with PARTITION BY department and ORDER BY date produces a cumulative running total within each department, because the default frame spans from the first row to the current row. Partitioning resets the accumulation per department, while the date ordering guarantees the running sequence the analyst requires.
- ✗
LAG(sales, 1) OVER (PARTITION BY department ORDER BY date)
Why it's wrong here
LAG returns the previous row's value, giving the prior date's sales figure rather than an accumulated total, so it cannot produce a running sum per department. It is tempting because it does use the same PARTITION BY department ORDER BY date framing, and it would be correct for comparing each day's sales against the preceding day's.
About these practice questions
One of 1,004 original DA0-002 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official CompTIA exam blueprint
This DA0-002 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DA0-002 exam.