Courseiva
Data Analysis →easyMultiple Choice

DA0-002 Data Analysis Practice Question

Exhibit

SELECT department, COUNT(*) as employee_count FROM employees WHERE hire_year > 2020 GROUP BY department HAVING COUNT(*) > 5;

Refer to the exhibit. Which clause is used to aggregate the data by department?

⚠ Common exam trap

CompTIA often tests the distinction between WHERE (row-level filter) and HAVING (group-level filter), leading candidates to confuse HAVING with GROUP BY when the question asks for the clause that performs aggregation.

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

✓

GROUP BY

The GROUP BY clause is used to aggregate data by department because it groups rows that have the same values in the specified column(s), allowing aggregate functions like SUM, AVG, or COUNT to be applied per group. In SQL, without GROUP BY, aggregate functions would operate on the entire result set, not per department.

Answer analysis

Option-by-option breakdown

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

  • ✗

    HAVING

    Why it's wrong here

    HAVING filters groups after GROUP BY has formed them; without GROUP BY present it cannot aggregate by department. It is the correct clause when filtering aggregated results, such as returning only departments whose total sales exceed a threshold.

  • ✗

    WHERE

    Why it's wrong here

    WHERE filters individual rows before any grouping occurs, so it cannot aggregate by department. It is the correct clause when restricting which source rows enter the query, such as selecting only records from a specific date range.

  • ✗

    ORDER BY

    Why it's wrong here

    ORDER BY sorts the result set after aggregation; it does not group rows, so it cannot aggregate by department. It is the correct clause when the requirement is to sequence output rows, for example listing departments alphabetically or totals descending.

  • ✓

    GROUP BY

    Why this is correct

    GROUP BY partitions rows sharing the same department value into groups, enabling aggregate functions such as COUNT, SUM or AVG to be computed per department. It is the clause that performs the grouping the question requires.

About these practice questions

This DA0-002 question is part of Courseiva's 1,004-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.