title: Fetching a value as a separate column depending on another column
body: <p>My data looks like:</p>
  
  <pre><code>col1    col2    attr    val
  ABC     123      A      10
  ABC     123      B      18
  XYZ     123      A      5
  XYZ     123      B      11
  ABC     888      A      24
  ABC     888      B      13
  XYZ     888      A      25
  .
  .
  .
  </code></pre>
  
  <p>Basically various combinations of col1,col2 exist; and corresponding to each <code>attr</code> associated with them, they have a separate record for <code>val</code>.</p>
  
  <p>I need the output in the form:</p>
  
  <pre><code>col1    col2   A_val    B_val
  ABC     123     10       18
  XYZ     123     5        11
  </code></pre>
  
  <p>(for each unique combination of <code>col1 col2</code>)</p>
  
  <p>This sort of a query is new territory for me, so I'm not sure where to start. It would probably involve something like a <code>CASE WHEN attr='A' THEN val END as A_val</code> but I'm not sure how to structure it.</p>