Ver Mensaje Individual
  #6  
Antiguo 19-01-2009
Avatar de poliburro
[poliburro] poliburro is offline
Miembro Premium
 
Registrado: ago 2004
Ubicación: México D.F
Posts: 3.068
Reputación: 23
poliburro Va por buen camino
Código SQL [-]
 
 
     Select Dias, 
                Sum(Case When tiempo<='00:30:0' Then 1 Else 0 End) As MenorIgual30,
                Sum(Case When (tiempo > '00:30:0') And (tiempo <= '00:59:00') Then 1 Else 0 End) As Entre30Y60,
                Sum(Case When tiempo<='00:30:0' Then 1 Else 0 End) + 
                Sum(Case When (tiempo > '00:30:0') And (tiempo <= '00:59:00') As Total 
       From Tiempo
Group By Dias
Union 
     Select 'Total2' As Dias, 
                Sum(Case When tiempo<='00:30:0' Then 1 Else 0 End) As MenorIgual30,
                Sum(Case When (tiempo > '00:30:0') And (tiempo <= '00:59:00') Then 1 Else 0 End) As Entre30Y60,
                Sum(Case When tiempo<='00:30:0' Then 1 Else 0 End) + 
                Sum(Case When (tiempo > '00:30:0') And (tiempo <= '00:59:00') As Total 
       From Tiempo


Para que la unión funcione sin problemas Dias debe ser convertido a cadena
__________________
Conoce mi blog http://www.edgartec.com
Responder Con Cita