title: SQL Results Set from List into grid
body: <p>I have two tables of data that I've joined.</p>
  
  <pre><code>Student 
  UPN | Name
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Subject
  UPN | Subject | Result
  </code></pre>
  
  <p>I have written the following query to bring out a list of all values.</p>
  
  <pre><code>SELECT student.upn,
         subject,
         result
  FROM   student
         JOIN subject
           ON subject.upn = student.upn
  </code></pre>
  
  <p>This results in the following</p>
  
  <pre><code>UPN             Subject       Result
  8152760         English       3c
  8138130         Spanish       2b
  8152760         Spanish       3c
  8128500         English       3c
  8152760         Mathematics   2b
  8152760         French        2b
  </code></pre>
  
  <p>What I would like to do is have the resultset display for each distinct student a column for each subject, so something like this:</p>
  
  <pre><code>UPN             English      French      Mathematics      Spanish
  8152760         3c           2b          2b               3c
  8138130         NULL         NULL        NULL             2b
  8128500         3c           NULL        NULL             NULL
  </code></pre>
  
  <p>Ideally I'd like it to auto generate the columns from my subject names, but I'm happy to hardcode them if this is more straightforward.</p>