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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Finding Previous Month values

kamranpathanMay 5 2010 — edited May 5 2010
Dear all....
My sample data is as follows:

CNS_DTE ELE_CNS
01-Feb-2010 5
02-Feb-2010 6
02-May-2010 1235
03-May-2010 2222
05-May-2010 1113

What I need from this data is I need current date value and SUM of previous month values. Current date in the sample data is 05-May-2010 and previous month can be any month lesser than current month i.e it can be April or March or Feb as its February in the above data. Result should be like this:

DATE CURRENT_VALUE PREVIOUS_VALUE
05-May-2010 1113 11

So could u write a smart query for this case??? I'm using DB 10g Rel.2

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 2 2010
Added on May 5 2010
5 comments
4,154 views