How to use Pivot for Two Columns

  • Step 1 would be to use datetime column instead of separate columns for year and moth.

    Then you'd be able to use PIVOT. Not just for PIVOT but as a better solution in general (unless there's a buch of constraints to make sure both columns are valid (e.g. Month only allows values from 1 to 12). The constraint would become slightly moredifficult if you'll need to check that there are no dates larger than today.

    Regardless of the table design, my preferred method would be the CrossTab method as described in the related link in my signature.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Thanks a lot for your help and cross tab article was really helpful.

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

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