title: Select inner join returns wrong result
body: <p>I'm using select inner join as below. How do I get my expected result?</p>
  
  <p>Here is the sql syntax:</p>
  
  <pre><code>select tgr.id, tgr.venid, sum(tgrd.qty*tgrd.pri), sum(tgrp.amo)
  from tgr inner join tgrd on tgr.id = tgrd.id
  inner join tgrp on tgr.id = tgrp.id
  where tgr.id = 3
  group by tgr.id, tgr.venid
  having sum(tgrd.qty*tgrd.pri)-sum(tgrp.amo)&gt;0;
  </code></pre>
  
  <p>result:</p>
  
  <pre><code>3 | 1 | 462000 | 262000
  </code></pre>
  
  <p>but I'm expecting result: </p>
  
  <pre><code>3 | 1 | 231000 | 131000
  </code></pre>
  
  <p>source from 3 tables: tgr, tgrd, tgrp</p>
  
  <pre><code>tgr table
  id  venid
  3   1
  
  tgrd table
  id  plu qty pri
  3   2   2.7 45000
  3   1   7.3 15000
  
  tgrp table
  id  type  amo
  3   2     0
  3   2     131000
  </code></pre>
  
  <p>Any help will be greatly appreciated.</p>