In a SQL query with a GROUP BY clause, every column you select must either 
be in the GROUP BY clause or have some aggregator function supplied.  If 
every "idproducto" has a single "image" associated with it, then the 
simplest solution is to add "image" to the GROUP BY clause:

SELECT image, idproducto, COUNT(cantidad) AS cantidad, SUM(precio) AS 
subtotal FROM carrito WHERE transaccion = 0 AND idusuario = 'david' GROUP 
BY idproducto, image

On Monday, January 7, 2013 1:52:43 AM UTC-5, Chrystopher Medina wrote:
>
>
> my friend could u explain me becaus this group by in my select query 
> doesn´t work,,
>
> i have this table:
>
> create table carrito (idusuario varchar(100),idproducto 
> varchar(100),cantidad int,precio float,transaccion int default 0,image 
> varchar(130));
>
>
> if i do this :  select idproducto,count(cantidad)as 
> cantidad,sum(precio)as subtotal from carrito where transaccion=0 and 
> idusuario='david' group by idproducto    
> IDPRODUCTO CANTIDAD SUBTOTALdc15      2                              780
> dc17      1499 dc01                              1250dc11       2180dc16      
> 1
> 999
>
> this works.   but loook this: seelct * from carrito,, here i have the rout 
> of an imagen and when i try to do this::
>
> its the same , but i want to show one more field witch is image
>
> select image,idproducto,count(cantidad)as cantidad,sum(precio)as subtotal 
> from carrito where transaccion=0 and idusuario='david' group by idproducto 
>   
>
> it doesn´t work ,,, shows me a meesage like this: ORA-00979: no es una 
> expresión GROUP BY
> IDUSUARIOIDPRODUCTO CANTIDAD PRECIOTRANSACCION IMAGE daviddc111900
> images/deportes/ciclismo/anforatermica.jpg daviddc111900
> images/deportes/ciclismo/anforatermica.jpg daviddc1513900
> images/deportes/ciclismo/multiplicadora.jpg daviddc1619990
> images/deportes/ciclismo/portabici.jpg daviddc1714990
> images/deportes/ciclismo/rines.jpg daviddc1513900
> images/deportes/ciclismo/multiplicadora.jpg daviddc0112500
> images/deportes/ciclismo/casco.jpg
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/7HpSqOcRcZ4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to