Help with PIVOT

  • Hi all,

    Can someone pls help me with the following? I'm trying to to do a few tests and to use PIVOT (for the first time) but couldn't get this work. Please see attachment.

    thank you.

    __________________________
    Allzu viel ist ungesund...

  • Mr. Holio (11/30/2011)


    Hi all,

    Can someone pls help me with the following? I'm trying to to do a few tests and to use PIVOT (for the first time) but couldn't get this work. Please see attachment.

    thank you.

    You have not included any code and have not described what you mean by "couldn't get this to work". Please provide more detail.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Try This.

    SELECT salaryrange,orders

    FROM

    (SELECT salaryrange, Col1, Col2, Col3, Col4, Col5

    FROM #salaryrange) p

    UNPIVOT

    (orders FOR ID IN

    ([Col1],[Col2],[Col3],[Col4],[Col5])

    )AS unpvt

    ORDER BY salaryrange;

    GO

  • indeed this should be UNPIVOT.. cheers Suresh.

    __________________________
    Allzu viel ist ungesund...

Viewing 4 posts - 1 through 3 (of 3 total)

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