title: SQL query: Recode value as new variable
body: <p>I am using a database that consist of answers to customer questionnaires. My problem is that while the customers has been asked several questions each, the number and specific questions vary and each question has its own record. So each questionnaire has three questions.</p>
  
  <p>I have grouped the question types and want one record for each questionnaire with all the answers.</p>
  
  <p>If qnumber [1,2,3],[4,5,6],[7,8,9] are the same and the info is like this</p>
  
  <pre><code>ID,qnumber,avalue  
  1,1,4  
  1,4,5  
  1,7,6  
  2,2,5  
  2,5,6  
  2,8,7  
  3,3,7  
  3,6,8  
  3,9,9  
  </code></pre>
  
  <p>I want to construct the query so a get a result like this:</p>
  
  <pre><code>ID,q1,q2,q3  
  1,4,5,6  
  2,5,6,7  
  3,6,7,8  
  </code></pre>
  
  <p>Is that even possible?</p>