title: MSSQL transpose multiple rows into one row(s) with columns
body: <p>I need to transform, transpose, whatever the right terminology is a data set with multiple rows and instead return a single row with multiple columns. Here is a sample of the data that I start with</p>
  
  <pre><code>EID               PM             Project     HOURS    WeekStarting
  joe@test.com      tom@test.com   Proj A       6         11/28/2016
  joe@test.com      tom@test.com   Proj A       3         12/5/2016
  joe@test.com      tom@test.com   Proj A       7         12/12/2016
  joe@test.com      tom@test.com   Proj A       3         12/19/2016
  sue@test.com      sam@test.com   Proj B       3         11/28/2016
  sue@test.com      sam@test.com   Proj B       6         12/12/2016
  sue@test.com      sam@test.com   Proj B       7         12/19/2016
  </code></pre>
  
  <p>I would like to format the data like so</p>
  
  <pre><code>EID            PM             Project    Week1  Week2 Week3  Week4 
  joe@test.com   tom@test.com   Proj A       6     3      7      3
  sue@test.com   sam@test.com   Proj B       3     0      6      7
  </code></pre>
  
  <p>Note that for sue there is no data in week2 in my source data so the result is 0 for week 2.</p>
  
  <p>Currently I am doing this in Javascript using the reduce function but it's very messy. I would rather try to fix the data and have clean Javascript.</p>
  
  <p>Any help is much appreciated.</p>