title: SQL query : transform rows to columns
body: <p>Here's an example of my table. </p>
  
  <p><a href="https://i.stack.imgur.com/dG8Ep.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dG8Ep.png" alt="enter image description here"></a></p>
  
  <p>I need to do a query that shows those IDs who have 0 as a fee on one of two months (11 or 12) or both.</p>
  
  <p>So from the example, I need to show ID 1,3,4 but not 2, like on the screenshot below.</p>
  
  <p><a href="https://i.stack.imgur.com/pKWSR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pKWSR.png" alt="enter image description here"></a></p>
  
  <p>I tried the query below:</p>
  
  <pre><code>SELECT 
      t1.id, t1.month, t1.fee, t2.id, t2.month, t2.fee
  FROM
      table t1, table t2
  WHERE t1.id = t2.id
    AND t1.month = '11'
    AND t2.month = '12'
    AND (t1.fee = 0 OR t2.fee = 0);
  </code></pre>
  
  <p>But with this query, I only see ID 1,3 but not ID 4. I guess it's because of <code>t1.id = t2.id</code> but no idea how to do otherwise.</p>