A data analyst has been asked to count the number of customers in each region and has written the following query: If there is a mistake in the query, which of the following describes the mistake?
A.
The query is using count(*), which will count all the customers in the customers table, no matter the region.
B.
The query is missing a GROUP BY region clause.
C.
The query is using ORDER BY, which is not allowed in an aggregation.
D.
There are no mistakes in the query.
E.
The query is selecting region, but region should only occur in the ORDER BY clause.
The mistake in the query is that it is missing a GROUP BY clause. When using an aggregate function like COUNT(*) in conjunction with non-aggregated columns like region, you need to include a GROUP BY clause to specify how the data should be grouped for the aggregation.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
MrWood47
11 months, 2 weeks ago