King

business intelligence ,is my love。

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

create table test_leiji(rpt_month_id number(8),
                        current_month NUMBER(12,2));

insert into test_leiji (RPT_MONTH_ID, CURRENT_MONTH) values (200901, 380128.344363);
insert into test_leiji (RPT_MONTH_ID, CURRENT_MONTH) values (200902, 274474.595772);
insert into test_leiji (RPT_MONTH_ID, CURRENT_MONTH) values (200903, 309427.898521);
insert into test_leiji (RPT_MONTH_ID, CURRENT_MONTH) values (200904, 379854.833875);

insert into test_leiji (RPT_MONTH_ID, CURRENT_MONTH) values (201001, 380128.344363);
insert into test_leiji (RPT_MONTH_ID, CURRENT_MONTH) values (201002, 274474.595772);
insert into test_leiji (RPT_MONTH_ID, CURRENT_MONTH) values (201003, 309427.898521);
insert into test_leiji (RPT_MONTH_ID, CURRENT_MONTH) values (201004, 379854.833875);


select  * from  test_leiji t


SELECT rpt_month_id,
       current_month,
       SUM (current_month) OVER (PARTITION BY SUBSTR (rpt_month_id, 1, 4)order by rpt_month_id) sum_month
  FROM test_leiji
  order by rpt_month_id;

显示结果如图:


 

posted on 2013-04-09 17:36  kingstudy  阅读(3386)  评论(1编辑  收藏  举报