Finding Previous Month values
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