Ver Mensaje Individual
  #30 (permalink)  
Antiguo 26/06/2008, 01:16
seyko
 
Fecha de Ingreso: febrero-2007
Mensajes: 1.292
Antigüedad: 17 años, 3 meses
Puntos: 13
Respuesta: Select Con Grupos¿?

Buenas Mayte, si partimos de que tienes algo asi:

Código:
select vehiculo, carga from tabla where condicion1
union all
select vehiculo, carga from tabla where condicion2
Y quieres que te salga el vehiculo y el numero de cargas, prueba algo como:
Código:
select vehiculo, sum(cargas) from (
select vehiculo, count(carga) as cargas from tabla where condicion1
union all
select vehiculo, count(carga) as cargas from tabla where condicion2
) foo
Salu2