Adding a count in cross tab data

  • There is a table showing below:

    A--B--C--D--COUNT

    X--X---------2

    ------X------1

    ------X--X---2

    X--X-X-------3

    ---X--X-------2

    For column A, B, C, D, how code to add total number in count column?

  • Option 1:

    SUM(CASE WHEN A='X' THEN 1 ELSE 0 END + CASE WHEN...END)

    Option 2: use UNPIVOT and the statement above on the resulting column.



    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]

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

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