- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
select
(CASE WHEN d.t1_aup_f IS NULL THEN (
CASE WHEN (lag(sum(d.t1_aup_f),1) over (order by d.real_day)) IS NULL THEN (
CASE WHEN (lag(sum(d.t1_aup_f),2) over (order by d.real_day)) IS NULL THEN (
/* ... */
CASE WHEN (lag(sum(d.t1_aup_f),28) over (order by d.real_day)) IS NULL THEN (
CASE WHEN (lag(sum(d.t1_aup_f),29) over (order by d.real_day)) IS NULL THEN
lag(sum(d.t1_aup_f),30) over (order by d.real_day )
ELSE (lag(sum(d.t1_aup_f),29) over (order by d.real_day)) END)
ELSE (lag(sum(d.t1_aup_f),28) over (order by d.real_day)) END)
ELSE (lag(sum(d.t1_aup_f),27) over (order by d.real_day)) END)
/* ... */
ELSE (lag(sum(d.t1_aup_f),2) over (order by d.real_day)) END)
ELSE (lag(sum(d.t1_aup_f),1) over (order by d.real_day)) END)
ELSE d.t1_aup_f END) gf_1
from sometable
таких полей было больше. тут http://paste.org.ru/?zlc3b8 - целиком. для полноты картины. надеюсь, не я написал, хотя... ))))
RomaShka 15.04.2011 09:26 # 0
guest 23.04.2011 12:26 # 0