Tema: Select case
Ver Mensaje Individual
  #8 (permalink)  
Antiguo 15/03/2013, 15:12
Bhrentox
 
Fecha de Ingreso: abril-2012
Mensajes: 11
Antigüedad: 12 años
Puntos: 1
Respuesta: Select case

Esta es la estructura de mi tabla de isr

+----+----------------+----------------+-----------+-----------+
| id | limiteinferior | limitesuperior | cuotafija | porciento |
+----+----------------+----------------+-----------+-----------+
| 1 | 0.01 | 244.80 | 0.00 | 0.02 |
| 2 | 244.81 | 2077.50 | 4.65 | 0.06 |
| 3 | 2077.51 | 3651.00 | 121.95 | 0.11 |
| 4 | 3651.01 | 4244.10 | 293.25 | 0.16 |
| 5 | 4244.11 | 5081.40 | 388.05 | 0.18 |
| 6 | 5081.41 | 10248.45 | 538.20 | 0.21 |
| 7 | 10248.46 | 16153.05 | 1641.75 | 0.24 |
| 8 | 16153.06 | | 3030.60 | 0.30 |
+----+----------------+----------------+-----------+-----------+

Cuando lanzo mi consulta x ejemplo esta :

Código:
select limiteinferior, porciento, cuotafija, limiteinferior=
case
when limiteinferior <=244.8 then 0.00
when limiteinferior >=244.81 and limitesuperior <= 2077.50 then 4.65
when limiteinferior >=2077.51 and limitesuperior <= 3651.00 then 121.95
when limiteinferior >=3651.01 and limitesuperior <= 4244.10 then 293.25
when limiteinferior >=4244.11 and limitesuperior <= 5081.40 then 388.05
when limiteinferior >=5081.41 and limitesuperior <= 10248.45 then 538.20
when limiteinferior >=10248.46 and limitesuperior <= 16153.05 then 1641.75
when limiteinferior >=16153.06  then 3030.60

end


from isr where limiteinferior <=20000.06 and limitesuperior >=20000.06;
Le estoy pidiendo que me devuelva el porciento, y la cuota fija correspondientes a este caso los cuales serian

121.95 | 0.11 |

Pero como te mencione anteriormente me devuelve un empty query

Si me falto de explicar algo x aca te respondo XD. salu2 y gracias x la ayuda