Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

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

Alfred88pp_0-1729881731256.png

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 

Alfred88pp_1-1729881812173.png

Somebody knows this error

Thx

 

 

   

0 2 1,079
2 REPLIES 2

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.