按日期导出拉链算法的历史值

select
sum( case when (t.beg_dt<='20150401' and t.end_dt>'20150401') then t.ac_bal else 0 end ) d1,
sum( case when (t.beg_dt<='20150402' and t.end_dt>'20150402') then t.ac_bal else 0 end ) d2,
sum( case when (t.beg_dt<='20150403' and t.end_dt>'20150403') then t.ac_bal else 0 end ) d3
from FNTACCBALHIS t where t.bal_typ=0 and chk_typ='1' and t.end_dt>'20150401' and t.beg_dt<='20150403'
group by t.inn_ac_no

posted @ 2015-05-07 18:48  顿金  阅读(298)  评论(0编辑  收藏  举报