title: DB2 (and Derby) Pivot Join with Case Statement
body: <p>I've seen this <a href="https://stackoverflow.com/questions/13579143/how-can-i-pivot-a-table-in-db2">SO question (How can I Pivot a table in DB2?)</a> and some of the answers/comments mention being able to acheive the same effect with a case statement but I'm struggling mightily to acheive this, probably due to a few years away from much SQL.</p>
  
  <p>Here is a snapshot of some data I have:</p>
  
  <pre><code>ID    Date          ErrID   ErrDesc
  ---------------------------------------
  164   2012-09-21    1402    Large V
  164   2012-09-21    1409    Missing
  416   2012-09-21    1409    Missing
  1380  2012-09-21    1411    n - Mis
  1500  2012-09-17    1411    n - Mis
  1500  2012-09-21    1402    Large V
  </code></pre>
  
  <p>ID <em>and</em> Date taken together need to be unique in a query that would return something such as the following, where the empty slots are null.  How can I achieve this, with a case statement or otherwise?  Bear in mind I don't think our version of DB2 supports "decode", and the SQL I need also needs to be able to run on Derby for testing.  Thanks in advance.</p>
  
  <pre><code>ID      Date        Err1402     Err1409     Err1411
  -----------------------------------------------------------------------
  164     2012-09-21  Large V     Missing
  416     2012-09-21              Missing
  1380    2012-09-21                          n - Mis
  1500    2012-09-17                          n - Mis
  1500    2012-09-21  Large V 
  </code></pre>