title: sum field only if another row with a special condition exists
body: <p>I have a table with the following entries:</p>
  
  <pre><code>id customer amount kind
  1  123      15     g
  2  123      30     op
  3  234      20     g
  4  345      25     g
  5  456      12     g
  6  456      15     op
  </code></pre>
  
  <p>What I want to do is to sum all amounts with the kind "g".</p>
  
  <p>Now I want to add a condition:</p>
  
  <p><strong>"Only sum the amount to the sum if there is another entry of the customer with the kind 'op'"</strong></p>
  
  <p>Means my result should be 27 in this case and not 72.</p>
  
  <p>What's a good way to add this condition?</p>
  
  <p>Thanks!</p>