I have one complex Decode statement that i can not able to understand it.
in the parameter it contains--> 1142009 <- as mmqyyyy formate.
Below is the code.
to_char(decode(substr('1142009',4,4),(to_char(sysdate,'yyyy')-2),
decode(substr('1142009',0,2),0,
decode(substr('1142009',3,1),0,12,
5,12,
1,03,
2,06,
3,09,
4,12,substr('1142009',0,2)),substr('1142009',0,2)),
decode(substr('1142009',4,4),(to_char(sysdate,'yyyy')-1),
decode(substr('1142009',0,2),0,
decode(substr('1142009',3,1),0,12,
5,12,
1,03,
2,06,
3,09,
4,12,substr('1142009',0,2)),substr('1142009',0,2)),
decode(substr('1142009',4,4),to_char(sysdate,'yyyy'),
decode(substr('1142009',0,2),0,
decode(substr('1142009',3,1),0,(to_char(r.reporting_date,'mm')-1),
5,to_char(r.reporting_date,'mm'),
1,03,
2,06,
3,09,
4,12,to_char(r.reporting_date,'mm')),substr('1142009',0,2))
,substr('1142009',0,2)))),'00') = pw.month_number <-----table column
Any kind of suggestion welcome.
Thanks.