Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sum previous month sales and current month sales

User_V2SACJan 19 2017 — edited Jan 19 2017

Hello All,

I have following data in my table (example only)

C_YEAR  C_MON  C_SALES   ID

======= ======= ========  ====

2016         Nov         100               1

2016         Dec         200               2

2015         Jan         150                2

2015         Feb         500               1

2015         Mar        200               1

2014         Oct          900               2

My input values are C_YEAR = 2015 and  C_MON=Mar

Expected Result:

C_SALES   ID

700            1

150               2

Tried roll_up option but I m able to rollup for each month. I am looking here if I enter feb it should rollup Jan+Feb. If I enter Nov it should rollup for Oct and November only.

Thanks for your help

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 16 2017
Added on Jan 19 2017
5 comments
1,101 views