aggregating non-numeric data into columns
Hi,
I'm pretty new to SQL and am hoping someone here can help me. I have a table of survey results where each record = one student's open-ended response to one question. Not every student answered every question, so the table looks like this:
userid | questionid | textresponse
101 | 35 | Here's a comment about question 35.
101 | 36 | Here's a comment about question 36.
101 | 37 | Here's a comment about question 37.
102 | 35 | I only wrote a comment about 35.
103 | 36 | I only wrote a comment about 36.
104 | 36 | Here's my answer for 36.
104 | 37 | Here's my answer for 37.
I want to write a query that creates a results set where each record = one userid, and each question is a column, like this:
userid | 35 | 36 | 37
101 | Here's a comment about question 35. | Here's a comment about question 36. | Here's a comment about question 37.
102 | I only wrote a comment about 35. | (null) | (null)
103 | (null) | I only wrote a comment about 36. | (null)
104 | (null) | Here's my answer for 36. | Here's my answer for 37.
Can someone give me instructions (geared for a beginner) on how to do this using Oracle 10g? Someone suggested the CUBE function, but that seems to be for aggregating non-numeric data. Any help would be greatly appreciated.