title: SQL transform table with sum based on values
body: <p>i have table like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>operation_id</th>
  <th>order_id</th>
  <th>qty</th>
  <th>qty_type</th>
  <th>detail_type</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>240</td>
  <td>ready</td>
  <td>glued</td>
  </tr>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>199</td>
  <td>ready</td>
  <td>unglued</td>
  </tr>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>100</td>
  <td>done</td>
  <td>glued</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>50</td>
  <td>ready</td>
  <td>glued</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>and would like to transform into this. it means to add 4 columns and to sum them from above table based on a conditions, like <code>detail_type = 'glued'</code>, <code>qty_type = 'ready'</code> etc.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>operation_id</th>
  <th>order_id</th>
  <th>qty_glued_ready</th>
  <th>qty_unglued_ready</th>
  <th>qty_glued_done</th>
  <th>qty_unglued_done</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>240</td>
  <td>199</td>
  <td>10</td>
  <td>10</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>can somebody help me how query should look like?</p>