An analyst is reviewing the above SQL query used to acquire data. What does this query retrieve?
The query groups orders by customer, filters transactions to the 2023 calendar year, applies a HAVING clause counting orders per customer, and returns only those exceeding five. This yields the set of customers meeting that order-frequency threshold within the specified period.
Why this answer
The SQL query uses a HAVING clause with COUNT(*) > 5 to filter customers who placed more than 5 orders in 2023. The WHERE clause restricts records to the year 2023, and the GROUP BY customer_id aggregates orders per customer. The condition '> 5' explicitly excludes customers with exactly 5 or fewer orders, making option A correct.
Exam trap
The trap here is confusing the comparison operator '>' with '>=', leading candidates to mistakenly include customers with exactly 5 orders when the query explicitly excludes them.
How to eliminate wrong answers
Option B is wrong because 'at least 5 orders' would require the condition COUNT(*) >= 5, not > 5. Option C is wrong because the query returns customer IDs, not the total number of orders per customer; the COUNT is used only for filtering, not as a selected column. Option D is wrong because 'exactly 5 orders' would require COUNT(*) = 5, not > 5.