Help needed to build a Partial transpose query or store procedure

  • I have a table described below

    Id personId YearJanAmt febAmtmarchamt

    1 300 1999$100$200$300

    2 444 2000$ 125$100$250

    3 111 2008$105$205$106

    I need to do a partial transpose as shown below:

    IDpersonId yearAmt

    13001999$100

    23001999$200

    33001999$300

    44442000$ 125

    54442000$100

    64442000$250

    71112008$105

    81112008$205

    91112008$106

    Any help will be appreciated.

  • How about:

    SELECT ID, PersonID, YEAR, Amount

    FROM YourTable

    UNPIVOT

    (Amount FOR MONTHS IN

    (JanAmt, FebAmt, MarAmt)) AS U

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply