Courseiva

DA0-002 Data Acquisition and Preparation Practice Question

A data analyst needs to count the number of customers who have placed at least one order. Which SQL query should be used?

⚠ Common exam trap

DA0-002 often tests the placement of DISTINCT inside the COUNT function — candidates who write SELECT DISTINCT COUNT(...) believe they are deduplicating, but DISTINCT applies to the aggregate result, not the input rows, so the count remains inflated.

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

✓

SELECT COUNT(DISTINCT customer_id) FROM orders

COUNT(DISTINCT customer_id) counts each unique customer exactly once, which is precisely what is needed to answer 'how many customers placed at least one order' — a customer with multiple orders is counted only once. This is the standard SQL pattern for counting distinct entities in a fact table.

Answer analysis

Option-by-option breakdown

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

  • ✗

    SELECT DISTINCT COUNT(customer_id) FROM orders

    Why it's wrong here

    DISTINCT applies to the result rows, so DISTINCT COUNT(customer_id) still evaluates COUNT first, yielding the same row count as a plain COUNT. It is tempting because DISTINCT is the usual deduplication tool, and it would be correct as SELECT COUNT(DISTINCT customer_id), which counts each customer once.

  • ✗

    SELECT SUM(customer_id) FROM orders

    Why it's wrong here

    SUM adds the numeric customer_id values together, producing a meaningless total rather than a count of distinct customers. It is tempting because SUM aggregates a column, and it would be correct when you need the arithmetic total of a numeric field, such as summing order amounts or quantities.

  • ✗

    SELECT COUNT(customer_id) FROM orders

    Why it's wrong here

    COUNT(customer_id) tallies every non-null row in orders, so a customer with three orders is counted three times, not once. It is tempting because COUNT is the counting aggregate, and it would be correct when you need the total number of order rows rather than the number of distinct customers.

  • ✓

    SELECT COUNT(DISTINCT customer_id) FROM orders

    Why this is correct

    COUNT(DISTINCT customer_id) eliminates duplicate customer identifiers before counting, so each customer contributes exactly one to the total regardless of how many orders they placed. This directly satisfies the stem's requirement to count customers with at least one order, rather than counting order rows themselves.

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 →

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.