Pivot Table Issue (Urgent)

  • Hi,

    I need help to solve following issue:-

    I have a table with following data

    Movi Sunday Monday Tuesday Wednesday Thrusday Friday Saturday

    1 0 0 1 1 1 1 1

    2 1 1 1 1 0 0 0

    3 1 1 1 1 1 1 1

    I need to have result into following set

    Days Count

    Sunday 2

    Monday 2

    Tuesday 3

    Wednesday 3

    Thrusday 2

    Friday 2

    Saturday 2

    Thanks!

    Naveen

  • SELECT Day

    , SUM([Count])

    FROM ( SELECT Sunday

    , Monday

    , Tuesday

    , Wednesday

    , Thrusday

    , Friday

    FROM mt

    ) p UNPIVOT ( [Count] FOR Day IN ( Sunday, Monday, Tuesday, Wednesday,

    Thrusday, Friday ) )AS unpvt

    GROUP BY Day

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • replace the 😉 with a ), and mt with the name of your table.

    - Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

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

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