Courseiva

DA0-002 Data Acquisition and Preparation Practice Question

An analyst needs to count the number of orders per customer but only for customers who have placed more than 5 orders. Which SQL construct allows filtering after aggregation?

⚠ Common exam trap

DA0-002 often tests the WHERE vs. HAVING distinction by presenting an aggregate filter and tempting candidates to pick WHERE because it is the more familiar filtering clause.

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

✓

HAVING COUNT(*) > 5

HAVING is the SQL clause specifically designed to filter groups after aggregation has been performed by GROUP BY. Because COUNT(*) is an aggregate function, it cannot be evaluated in the WHERE clause, which runs before grouping. HAVING executes after GROUP BY and aggregation, so it can reference aggregate results like COUNT(*) > 5.

Answer analysis

Option-by-option breakdown

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

  • ✗

    WHERE COUNT(*) > 5

    Why it's wrong here

    WHERE is evaluated before GROUP BY, so aggregate functions such as COUNT(*) are unavailable at that stage; the query fails. It tempts because WHERE filters rows, but restricting groups by an aggregate value requires HAVING, which runs after aggregation.

  • ✗

    LIMIT 5

    Why it's wrong here

    LIMIT restricts the number of returned rows after ordering; it cannot filter groups by an aggregate count. It tempts because it appears to cap results at five, but the requirement needs HAVING with COUNT(*) applied to the grouped customers.

  • ✓

    HAVING COUNT(*) > 5

    Why this is correct

    HAVING filters grouped rows after aggregation, unlike WHERE, which filters individual rows before grouping. Because the requirement is to count orders per customer and then retain only those exceeding five, HAVING COUNT(*) > 5 applies the condition to the aggregated count, satisfying the post-aggregation filtering constraint in the stem.

  • ✗

    ORDER BY COUNT(*) > 5

    Why it's wrong here

    ORDER BY sorts the result set; it cannot restrict rows, so COUNT(*) > 5 here is a boolean expression evaluated per row for sorting, not a filter. It is tempting because ORDER BY does reference aggregates, but filtering on an aggregate requires HAVING after GROUP BY.

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.