Courseiva

DA0-002 Data Acquisition and Preparation Practice Question

A data analyst needs to count the number of distinct product categories in a table named 'products'. Which SQL function should be used in the SELECT clause?

⚠ Common exam trap

Candidates often confuse the correct placement of DISTINCT within the COUNT function; many candidates mistakenly write DISTINCT COUNT() or COUNT() DISTINCT, or they forget that COUNT(*) with a WHERE clause does not deduplicate.

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

✓

COUNT(DISTINCT category)

The correct syntax to count unique non-null values in a column is COUNT(DISTINCT column_name). This function first eliminates duplicate values in the specified column and then counts the remaining distinct entries. In this scenario, COUNT(DISTINCT category) will return the number of unique product categories present in the 'products' table, ignoring any NULLs.

Answer analysis

Option-by-option breakdown

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

  • ✗

    COUNT(category)

    Why it's wrong here

    COUNT(category) tallies every non-null row, so duplicate categories inflate the result. It is correct when counting total products per category or rows overall, but the stem asks for distinct categories, which requires COUNT(DISTINCT category) to deduplicate values before counting.

  • ✗

    DISTINCT COUNT(category)

    Why it's wrong here

    DISTINCT COUNT(category) is invalid SQL syntax; DISTINCT is a keyword inside COUNT, not a standalone function. It would be tempting if such a function existed, but the correct form is COUNT(DISTINCT category), which deduplicates values before tallying them.

  • ✓

    COUNT(DISTINCT category)

    Why this is correct

    COUNT(DISTINCT category) returns the number of unique category values, satisfying the requirement to count distinct categories rather than all rows. Plain COUNT(category) would include duplicates and ignore nulls, so DISTINCT is essential to the stated goal.

  • ✗

    COUNT(*) WHERE category IS NOT NULL

    Why it's wrong here

    COUNT(*) with a NOT NULL filter counts rows, not distinct values, so repeated categories are counted multiple times. It suits counting total non-null records, but the requirement is the number of unique categories, which only COUNT(DISTINCT category) returns.

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.