Ver Mensaje Individual
  #2 (permalink)  
Antiguo 22/04/2014, 00:58
quimfv
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: Agrupar cantidades por precios

Código MySQL:
Ver original
  1. SELECT Sbc.codigo, group_concat( CONCAT( Sbc.Tcantidad, 'x', FORMAT(Sbc.precio, 2 ) )
  2. SEPARATOR '+' ) AS ventas
  3. SELECT codigo,precio,SUM(cantidad) Tcantidad
  4.    FROM detalle_ventas
  5.    GROUP BY codigo,precio) Sbc
  6. GROUP BY Sbc.codigo

Eso sirve?
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.