Subject Turning rows into columns
Author Raigo
Hi

How to turn rows of a query into columns?

a poll system has a table.

create table answers (
Questionnaire_ID Integer,
Question_ID varchar(5),
Answer Integer
...
);

All answers are Radio type (options 1, 2,...5).
I am asked to create results in table like this example

Question1, Question2, Question3 etc. (Question_ID)
Questionnaire1 1 3 5
Questionnaire2 4 2 2
Questionnaire3 5 1 3
Questionnaire4 3 2 4
etc.
(Questionnaire_ID)



first row is Question ID's
first column is Questionnaire's (one answerer form).
Answers are where column and questionnaire cross.


Any ideas how generate this sort of resultset in a query or SP ?