SELECT list expression references column ` SubTotal ` which is neither grouped nor aggregated at [2:

Hi there can you help with that

In the first image I copy the same to query and that works exccellenty

And the second imagen despite copy the same to query and add another syntax I add GROUP BY at moment it gives me an error

Somebody knows this error

Thx

Try this:

SELECT
  SUM(SubTotal),
  <your code before group by clause>
GROUP BY Razon_emisor, Fecha_certificacion
  <rest of your code>

Hi @Alfred88pp ,

Welcome to Google Cloud Community!

The error message “SELECT list expression references column 'SubTotal' which is neither grouped nor aggregated at [2.3]” means any columns that you SELECT must also either be included in the GROUP BY or be used in an aggregation function.

Consider these options to solve the issue:

  • Use aggregate functions to calculate a summary based on the values within each group ( COUNT(), MAX(), MIN(), SUM(), AVG() ), as shown in @mars124 ’s sample query.
  • Include ‘Subtotal’ in GROUP BY if you want to see all the individual ‘SubTotal’ values along with the grouped ‘Razon emisor’.

I hope the above information is helpful.