Skip to content

Instantly share code, notes, and snippets.

@mikel
Created October 25, 2010 10:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikel/644764 to your computer and use it in GitHub Desktop.
Save mikel/644764 to your computer and use it in GitHub Desktop.
I need SQL to turn this:
| user_id | question_name | answer |
| 1 | 'q1' | 'a' |
| 1 | 'q2' | 'b' |
| 1 | 'q3' | 'c' |
| 2 | 'q1' | 'd' |
| 2 | 'q2' | 'e' |
| 2 | 'q3' | 'f' |
Into this:
| user_id | q1 | q2 | q3 |
| 1 | 'a' | 'b' | 'c' |
| 2 | 'd' | 'e' | 'f' |
Obviously the data is a lot more complex, but I need the basic idea to get me started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment