Is it possible to transpose a table with repeated columns?
Existing table:
user_id question_id body
1 1 'Text1 1'
1 1 'Text1 1-2'
1 2 'Text1 2'
1 3 'Text1 3'
2 1 'Text2 1'
2 2 'Text2 2'
Cross tab or solution based on
MAX(CASE WHEN r.question_id = 1 THEN r.body ELSE NULL END) AS 'question1'
is not applicable in this scenario because always is match last occurance of repeated attribute.
I want to perform search on the question body but I don't know how without a transposed table.
E.g. I want to find user_id where question1='...' AND question2='...'