0

I have a table like:

Survey Result

SurveyId Int ex. 12
QuestionName Varchar ex. A18a
QuestionValue Int ex. 2

I am trying to write a query that would set the values of QuestionName as columns horizontally, by SurveyId. If there is no entry for a certain question, that value would read NULL. The result would look like:

SurveyId | A01 | A02 | A03 | A04...
12 | 1 | 4 | 3 | NULL...
213 | 2 | 5 | NULL | NULL ...

I can't figure out how to select the questions as column titles. Is there an easy way of accomplishing this? Any help would be appreciated.

citizenen
  • 703
  • 6
  • 24

1 Answers1

0

This basically is a pivot table.

A nice tutorial on how to archive this can be found here: http://www.artfulsoftware.com/infotree/queries.php#78

I advise reading this post and adapt this solution to your needs.

Romil Kumar Jain
  • 20,239
  • 9
  • 63
  • 92