title: Joining with conditions
body: <p>I have the following tables:</p>
  
  <pre><code>**payments**
  ID  Sum
  1   400
  2   450
  3   500
  
  **orders**
  ID  Payment
  1   1       
  2   3
  3   2
  
  **orders_info**
  ID  ItemID  Qty Sum
  1   1       1   400
  2   12      2   225
  3   8       1   500
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>payments.ID = orders.Payment
  orders.ID = orders_info.ID
  </code></pre>
  
  <p>Now, if I join this up like below I'm gonna get wrong result:</p>
  
  <pre><code>select o.ID, sum(qty*sum)
  from payments p
    inner join orders o on(p.ID = orders.Payment)
    inner join orders_info oi on(o.ID = oi.ID)
  where oi.Qty &lt; 2
  group by o.ID
  </code></pre>
  
  <p>If I join like this, I'm gonna get way too many rows and therefor the sum() function will return a too high value. I need the info from orders_info without having to multiply its rows with the other tables. How can I achieve this? </p>
  
  <p>So, basicly I want to have all payments made along with their value gotten from the order_info except if the qty is for example lesser than 2.</p>