Ver Mensaje Individual
  #6  
Antiguo 02-09-2006
Avatar de taru
taru taru is offline
Miembro
 
Registrado: jul 2006
Posts: 27
Reputación: 0
taru Va por buen camino
Gracias Tony_G Pero no funciona te comento:
Código SQL [-]
SELECT IF (sum(ingresos.ingreso) > ticket.ptotal, ticket.ptotal, sum(ingresos.ingreso)) as totalingresos
FROM ticket LEFT JOIN ingresos ON ticket.id = ingresos.idticket
WHERE DAY(ingresos.fecha)=2
GROUP BY ticket.id  WITH ROLLUP;
y me da como resultado:
30
90
150
198
10
30

el rollup añade el 30 final
lo anterior al 30 esta todo correctamente incluso si hago el select de esta forma:
Código SQL [-]
SELECT ticket.id, IF (sum(ingresos.ingreso) > ticket.ptotal, ticket.ptotal, sum(ingresos.ingreso)) as totalingresos
FROM ticket LEFT JOIN ingresos ON ticket.id = ingresos.idticket
WHERE DAY(ingresos.fecha)=2
GROUP BY ticket.id  WITH ROLLUP;
veo el id de los ticket y el null final, De todas formas gracias por lo del roolup no lo conocia ya he visto tb el CUBE:
148, 30
150, 90
154, 150
158, 198
162, 10
, 30
Responder Con Cita