title: Rearrange Dataset
body: <p>I am working on some survey data and was wondering if i could rearrange the data to make it a lot more usable. The results are classified as 1-5 and I would like the preferred table to count the results by value and group by question.</p>
  
  <p>original table:</p>
  
  <pre><code>year | month | customer_id | survey | q1 | q2 | q3 | q4 | q5 | q6 ----&gt; q29
  -----|-------|-------------|--------|----|----|----|----|----|---
  2016 | Oct   | ABC12345678 | 1      | 1  | 2  | 3  | 1  | 2  | 3 
  2016 | Oct   | DEF12345678 | 1      | 2  | 1  | 4  | 2  | 1  | 1
  2016 | Oct   | GHI12345678 | 1      | 4  | 2  | 1  | 1  | 3  | 2 
  2016 | Oct   | JKL12345678 | 1      | 2  | 3  | 2  | 4  | 1  | 3 
  2016 | Oct   | MNO12345678 | 1      | 5  | 2  | 3  | 1  | 2  | 3 
  2016 | Oct   | PQR12345678 | 1      | 3  | 4  | 4  | 2  | 4  | 4 
  2016 | Oct   | STU12345678 | 1      | 1  | 5  | 3  | 1  | 2  | 5 
  2016 | Oct   | VWX12345678 | 1      | 2  | 2  | 4  | 2  | 1  | 1 
  </code></pre>
  
  <p>Preferred Table:</p>
  
  <pre><code>Year | Month | Survey | Question | 1  | 2  | 3  | 4  | 5  |
  -----|-------|--------|----------|----|----|----|----|----|
  2016 | Oct   |   1    |   q1     | 80 | 45 | 25 | 63 | 89 |  
  2016 | Oct   |   1    |   q2     | 65 | 75 | 35 | 53 | 69 |  
  </code></pre>
  
  <p>I can do this with a basic select query but to do it for every question will end up with 29 unions and there must be a quicker way.</p>
  
  <p>Regards,</p>
  
  <p>Neil</p>