title: Presto SQL pivoting (for lack of a better word) data
body: <p>I am working with some course data in a Presto database. The data in the table looks like:</p>
  
  <pre><code>student_id  period   score completed
  1           2016_Q1  3     Y
  1           2016_Q3  4     Y
  3           2017_Q1  4     Y
  4           2018_Q1  2     N
  </code></pre>
  
  <p>I would like to format the data so that it looks like:</p>
  
  <pre><code>student_id  2018_Q1_score 2018_Q1_completed 2017_Q3_score
  1           0             N                 5
  3           4             Y                 4
  4           2             N                 2
  </code></pre>
  
  <p>I know that I could do this by joining to the table for each time period, but I wanted to ask here to see if any gurus had a recommendation for a more scalable solution (e.g. perhaps not having to manually create a new join for each period). Any suggestions? </p>