10/02/2009, 10:16
|
| | | Fecha de Ingreso: agosto-2007
Mensajes: 1.338
Antigüedad: 17 años, 4 meses Puntos: 18 | |
Respuesta: Consulta de contar y sumar por tramos. No se si te he entendido:
SELECT
Sum(IIf([metros]=0,1,0)) AS iguala0,
Sum(IIf([metros]>=0 And [metros]<=100000000000,1,0)) AS todos,
Sum(IIf([metros]>=1 And [metros]<=100,1,0)) AS entre1y100,
Sum(IIf([metros]>=101 And [metros]<=500,1,0)) AS entre101y500,
Sum(IIf([metros]>=501 And [metros]<=1000,1,0)) AS entre501y1000,
Sum(IIf([metros]>=1001 And [metros]<=5000,1,0)) AS entre1001y5000,
Sum(IIf([metros]>=5000,1,0)) AS superiora5000, Sum(IIf([metros]=0 ,[elec_consumo2006],0)) AS sumaIgualACero_,
Sum(IIf([metros]>=1 And [metros]<=100,[elec_consumo2006],0)) AS sumaentre1y100_,
Sum(IIf([metros]>=101 And [metros]<=500,[elec_consumo2006],0)) AS sumaentre101y500_,
Sum(IIf([metros]>=501 And [metros]<=1000,[elec_consumo2006],0)) AS sumaentre501y1000_,
Sum(IIf([metros]>=1001 And [metros]<=5000,[elec_consumo2006],0)) AS sumaentre1001y5000_,
Sum(IIf([metros]>=5000,[elec_consumo2006],0)) AS sumasuperiora5000_
FROM basegeneral;
Un saludo |