title: SQL select: two-dimensional select with variable column count
body: <pre><code>CREATE TABLE activities(activityid, name);
  CREATE TABLE activity_scores(activityid, studentid, score);   
  CREATE TABLE students (id, name);
  </code></pre>
  
  <p>Is there any way to write a single SELECT query that will produce one result for each student, in this format?</p>
  
  <pre><code>studentid | studentname | activity1_score | activity2_score | activity3_score [...]
  </code></pre>
  
  <p>It's trivial to do it with multiple queries:</p>
  
  <pre><code>for each studentid in "select id from students":
      print studentid
      for each activity in "select activityid from activities":
          select score from activity_scores where studentid = studentid
          print score
  </code></pre>
  
  <p>(pseudocode, I know it's not accurate)</p>
  
  <p>Surely there's a way to create this result with a single SELECT query, right?</p>