title: Postgres rows to columns
body: <p>I have read a lot of questions on how to "transpose" or pivot data i Postgres but nothing has given me enough to see if the thing I am trying to do is even possible.</p>
  
  <p>Given a set of data in a Postgres table like this:</p>
  
  <pre><code>issue       valid       station     value
  2013-02-01  2013-02-01  A           1
  2013-02-01  2013-02-02  A           1.2
  2013-02-01  2013-02-03  A           1.3
  2013-02-01  2013-02-04  A           1.0
  2013-02-01  2013-02-01  B           2.1
  2013-02-01  2013-02-02  B           2.1
  2013-02-01  2013-02-03  B           2.4
  2013-02-01  2013-02-04  B           2.7
  2013-02-01  2013-02-01  C           3.2
  2013-02-01  2013-02-02  C           3.7
  2013-02-01  2013-02-03  C           3.5
  2013-02-01  2013-02-04  C           3.5
  </code></pre>
  
  <p>I would like to be able make a query that if I set <code>issue=2013-02-01</code> results in:</p>
  
  <pre><code>station  val_day1  day1        val_day1  day2        val_day3  day3        val_day4  day4        max_val
  A        1         2013-02-01  1.2       2013-02-02  1.3       2013-02-03  1.0       2013-02-04  1.3     
  B        2.1       2013-02-01  2.1       2013-02-02  2.4       2013-02-03  2.7       2013-02-04  2.7 
  C        3.2       2013-02-01  3.7       2013-02-02  3.5       2013-02-03  3.5       2013-02-04  3.7
  </code></pre>
  
  <p>Unfortunately I am very limited in what I can change so if this is possible to solve in a sql query that would be awesome.</p>
  
  <p>The data has always 4 different days as "valid" for each issue. A new issue is added every day.</p>
  
  <p>Is this even possible to try to get going in Postgres?</p>
  
  <p>Thanks</p>