I have 3 tables.
1 - Student
| student_code | name |
--------------------------
| 1 | katia |
| 2 | roger |
| 3 | ken |
2 - Question
| question_code| question |
----------------------------------
| 1 | father' name |
| 2 | favorite fruit |
| 3 | first teacher |
3 - Answers
| student_code | question_code | answer |
-------------------------------------------
| 1 | 1 | katia |
| 1 | 2 | banana |
| 2 | 1 | ken |
When I join this 3, I've 800.000 rows like this:
| name | question | answer |
-------------------------------------
| katia| favorite fruit | banana |
| katia| father's name | paul |
| roger| father's name | aaron |
I need convert the questions rows for columns and maintain only 1 student per row.
I've searched for pivot table but I can't make it works.
OBS: Not every student has all questions
EDIT: I think this question is not duplicated because PIVOT function is very specific , the other question doesn't answer the mine.