Courseiva

DA0-002 Data Acquisition and Preparation Practice Question

You are analyzing sales data and need to calculate the moving average of monthly sales over the previous 3 months for each month. Which type of function is best suited for this task?

⚠ Common exam trap

The trap is choosing GROUP BY because 'average' sounds like an aggregate — but GROUP BY collapses rows, whereas a moving average requires per-row output, which only window functions provide.

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

✓

Window function with OVER()

A window function with OVER() computes a value across a defined set of rows related to the current row without collapsing them, which is exactly what a moving average over the previous 3 months requires. The OVER() clause defines the window (e.g., ROWS BETWEEN 2 PRECEDING AND CURRENT ROW), and the aggregate (AVG) is applied per row while preserving all rows.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    String function

    Why it's wrong here

    String functions manipulate text characters, so they cannot compute a rolling mean across numeric sales rows. They are tempting because month labels are text, but the calculation needs a windowed aggregate over ordered rows, not concatenation or substring operations.

  • ✓

    Window function with OVER()

    Why this is correct

    A window function with OVER() computes an aggregate across a defined frame of preceding rows while retaining each row's detail. This satisfies the three-month moving average requirement, which GROUP BY cannot produce without collapsing the monthly rows.

  • ✗

    Aggregate function with GROUP BY

    Why it's wrong here

    GROUP BY collapses each month into one aggregated row, destroying the per-month detail a three-month moving window requires. It is tempting because it does aggregate sales, but it is correct for totals per category, not for sliding windows across consecutive periods.

  • ✗

    Date function

    Why it's wrong here

    Date functions extract or manipulate date components such as month or year; they do not compute a rolling three-month average across ordered rows. They are tempting because the data is monthly, but the task needs a window function with a ROWS BETWEEN frame.

About these practice questions

Courseiva writes every DA0-002 question from scratch — 1,004 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 →

How Courseiva writes practice questions · Editorial policy

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.