Reputation: 9
Here's my code:
SELECT
COUNT(customer_id) AS id_count,
purchase_price,
purchase_size
FROM
charjx-project-twenty-three.customer_data1.customer_purchase
WHERE
purchase_size > 1
ORDER BY
purchase_size
Error message is:
SELECT list expression references column purchase_price which is neither grouped nor aggregated at [3:3]
I'm super new to SQL. So I'm learning the Ins and outs, especially with errors.
Upvotes: 0
Views: 40
Reputation: 1075
As you are using aggregate function COUNT
, other columns must be in the GROUP BY
clause so that aggregate function can provide you the aggregated result based on the grouped columns.
You just need to include GROUP BY
as follows:
WHERE
purchase_size >1
GROUP BY
purchase_price,
purchase_size
ORDER BY
purchase_size
Upvotes: 2