
Optimizar consulta
Publicado por jose manuel (23 intervenciones) el 27/08/2016 01:18:18
tengo una consulta que quisiera optimizar, ante todo es por que me marca una division de error en cero pero no la encuentro
por su ayuda mil gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
select a.*
FROM(select round(
CASE hora
WHEN '06:30:00:000' THEN (isnull(fem_ah17/2,0))*.000947
WHEN '07:00:00:000' THEN (isnull(fem_ah17/2,0))*.000947
WHEN '14:30:00:000' THEN (isnull(fem_ah17/2,0))*.000947
WHEN '15:00:00:000' THEN (isnull(fem_ah17/2,0))*.000947
ELSE (isnull(fem_ah17,0))*.000947 END /(isnull(bpw_2,1)),5) as real ,
CASE hora
WHEN '06:30:00:000' THEN (isnull(fem_ah17/2,0))*.000947
WHEN '07:00:00:000' THEN (isnull(fem_ah17/2,0))*.000947
WHEN '14:30:00:000' THEN (isnull(fem_ah17/2,0))*.000947
WHEN '15:00:00:000' THEN (isnull(fem_ah17/2,0))*.000947
ELSE (isnull(fem_ah17,0))*.000947 END as dato,
isnull(bpw_2,0) as ton, fecha+hora as fecha,hora
from basculasreal
where fecha between @FechaI and @FechaF and bpw_2>0 ) a where real<300 order by fecha
por su ayuda mil gracias
Valora esta pregunta


0