日期:2014-05-17 浏览次数:20915 次
第二题: select t.*, sum(sal) over(order by statdate rows 12 preceding) "前十二个月和" from test_kpi_busi_claim_mon t STATDATE RISKCODE A1 SAL 前十二个月和 ----------- -------- -- --- ------------ 2009-1-31 0104 0 3 3 2009-2-28 0104 0 3 6 2009-3-31 0104 0 3 9 2009-4-30 0104 0 3 12 2009-5-31 0104 0 4 16 2009-6-30 0104 0 4 20 2009-7-31 0104 0 4 24 2009-8-31 0104 0 4 28 2009-9-30 0104 0 5 33 2009-10-31 0104 0 5 38 2009-11-30 0104 0 5 43 2009-12-31 0104 0 5 48 2010-1-31 0104 0 0 48 2010-2-28 0104 0 0 45 2010-3-31 0104 0 0 42 2010-4-30 0104 0 1 40 2010-5-31 0104 0 1 38 2010-6-30 0104 0 1 35 2010-7-31 0104 0 1 32 2010-8-31 0104 0 1 29 STATDATE RISKCODE A1 SAL 前十二个月和 ----------- -------- -- --- ------------ 2010-9-30 0104 0 1 26 2010-10-31 0104 0 2 23 2010-11-30 0104 0 2 20 2010-12-31 0104 0 3 18 2011-1-31 0104 0 0 13 2011-2-28 0104 0 0 13 2011-3-31 0104 0 0 13 2011-4-30 0104 0 0 13 2011-5-31 0104 0 0 12 2011-6-30 0104 0 0 11 2011-7-31 0104 0 6 16 2011-8-31 0104 0 6 21 2011-9-30 0104 0 6 26 2011-10-31 0104 0 6 31 2011-11-30 0104 0 6 35 2011-12-31 0104 0 9 42 2012-1-31 0104 0 0 39 37 rows selected