DA0-002 Data Analysis Practice Question
Exhibit
Refer to the exhibit. SELECT customer_id, COUNT(order_id) AS order_count FROM orders WHERE order_date BETWEEN '2023-01-01' AND '2023-12-31' GROUP BY customer_id HAVING COUNT(order_id) > 5;
The exhibit shows an SQL query executed on an 'orders' table that contains 'order_id', 'customer_id', and 'order_date'. What is the purpose of this query?
⚠ Common exam trap
CompTIA often tests the distinction between WHERE and HAVING, and the trap here is confusing a count of orders per customer with a count of products or an average, leading candidates to pick option B or C.
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
✓
Identify customers who placed more than 5 orders in 2023
The query groups orders by customer_id and filters using a HAVING clause with COUNT(*) > 5, which counts the number of orders per customer. The WHERE clause restricts orders to those placed in 2023, so the result identifies customers who placed more than 5 orders in that year. This matches option D exactly.
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 total orders per customer regardless of date
Why it's wrong here
The query groups by customer and counts orders, but the stem's table includes order_date, implying a date filter or grouping that this option ignores. It would be correct only if no date condition appeared in the query.
- ✗
Calculate average order count per customer for 2023
Why it's wrong here
The query returns each customer's total 2023 orders, not an average. Averaging requires an aggregate such as AVG applied to a per-customer count, typically via a subquery or window function. This option tempts because GROUP BY customer_id with COUNT(*) genuinely supports per-customer averaging when the stem's query includes that outer aggregation.
- ✗
Find products with more than 5 orders in 2023
Why it's wrong here
The query groups by customer_id, not by product, and the orders table holds no product column, so product-level counts cannot be produced. Counting orders per customer is what it does; identifying best-selling products would require joining an order-items or products table first.
- ✓
Identify customers who placed more than 5 orders in 2023
Why this is correct
The query groups orders by customer_id, filters order_date to the 2023 range, and applies a HAVING count greater than five. This returns customers whose 2023 order count exceeds five, satisfying the stated purpose of identifying high-frequency customers.
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 →
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.