Counts and Group By with more than one column

  • Hi.

    I have the following two tables:

    Table1 [Organisation, ProjectName]

    Table2 [ProjectName, Question, Answer]

    I would like to use a SELECT statement to create the following:

    [Organisation, Count of responses to question 1, Count of responses to question 2]

    i.e. A table with three columns, grouped by Organisation. The first column will be the name of the Organisation, the second column will be a count of all the times a person in that organisation has answered question 1, and the third column will be a count of all the times a person in that organisation has answered question 2.

    Any help much appreciated!

    Mark

  • I am guessing its a case of PIVOT. Please provide the data in the format as described in the link below. Thanks.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    ---------------------------------------------------------------------------------

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

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