1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Oracle help for building a relationship betwwen months

Discussion in 'SQL PL/SQL' started by gauravgoyaldlp, Jan 20, 2015.

  1. gauravgoyaldlp

    gauravgoyaldlp Active Member

    Likes Received:
    Trophy Points:

    I have a month table where we are storing months from 1994 to 2030 in the form of 1994M01, 1994M02, 1994M03....1994M12, 1995M01 and so on. By using this I need to populate one relation table as below.

    month_id Rolling_month rolling_prev_month rank
    2015M01 2015M01 2014M01 1
    2015M01 2014M12 2013M12 2
    2015M01 2014M11 2013M11 3
    2015M01 2014M10 2013M10 4
    2015M01 2014M09 2013M09 5
    2015M01 2014M08 2013M08 6
    2015M01 2014M07 2013M07 7
    2015M01 2014M06 2013M06 8
    2015M01 2014M05 2013M05 9
    2015M01 2014M04 2013M04 10
    2015M01 2014M03 2013M03 11
    2015M01 2014M02 2013M02 12
    2014M12 2014M12 2013M12 1
    2014M12 2014M11 2013M11 2
    2014M12 2014M10 2013M10 3
    2014M12 2014M09 2013M09 4
    2014M12 2014M08 2013M08 5
    2014M12 2014M07 2013M07 6
    2014M12 2014M06 2013M06 7
    2014M12 2014M05 2013M05 8
    2014M12 2014M04 2013M04 9
    2014M12 2014M03 2013M03 10
    2014M12 2014M02 2013M02 11
    2014M12 2014M01 2013M01 12

    Can anyone help me to achive this by using oracle query or procedure??

    Thanks in advance!