What does it mean when Big Query shows this error message?

35 views Asked by At

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.

1

There are 1 answers

0
ORA-01017 On

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