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
原文:http://www.cnblogs.com/dashi/p/4485770.html