DA0-002 Data Acquisition and Preparation Practice Question
A data analyst needs to calculate the running total of sales for each product over time. Which window function clause is essential for this calculation?
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
✓
PARTITION BY product_id ORDER BY sale_date
For a running total of sales for each product over time, you must group the calculation by product (PARTITION BY product_id) and order by sale_date (ORDER BY sale_date). The default window frame in SQL (RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) suffices for running totals. Option B provides both PARTITION BY product_id and ORDER BY sale_date, making it essential.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
ORDER BY sale_date ROWS BETWEEN 1 PRECEDING AND CURRENT ROW
Why it's wrong here
Incorrect. 'ROWS BETWEEN 1 PRECEDING AND CURRENT ROW' creates a moving sum of only two rows, not a running total, and lacks PARTITION BY for per-product calculation.
- ✓
PARTITION BY product_id ORDER BY sale_date
Why this is correct
Correct. Contains both PARTITION BY product_id (for per-product totals) and ORDER BY sale_date (for ordering over time), which together enable a running total with the default frame.
- ✗
PARTITION BY product_id
Why it's wrong here
Incorrect. 'PARTITION BY product_id' without ORDER BY does not define an order, so it cannot produce a running total over time.
- ✗
ORDER BY sale_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
Why it's wrong here
Incorrect. 'ORDER BY sale_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW' gives a running total over all sales, not per product, because it lacks PARTITION BY product_id.
Go deeper
Related to this question
About these practice questions
Courseiva writes every DA0-002 question from scratch — 986 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.