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;
Show results
Oracle Current month adds a column showing cumulative values for previous months