title: SUM function add records twice
body: <p>I have 2 records amount in my database and i have to use sum function to display the total of amount but it shows and sums twice</p>
  
  <p>I have tried the other sum function in the same query and its working but when i use it second time, it sums twice.</p>
  
  <pre><code>$sql = "SELECT 
                  mm.idno as idno,
                  TRIM(UPPER(CONCAT(mm.fname, ' ', mm.mname, ' ', mm.lname))) as fullname, 
                  TRIM(UPPER(mm.branchname)) as branchname, 
                  TRIM(UPPER(mm.address)) as outlet_address, 
                  SUM(dr.totalamt) as total_amount,
                  SUM(drr.totalamt) as return_amount  
          FROM 8_membermain mm
              LEFT JOIN 8_directsalessummary dr ON mm.idno = dr.idno
              LEFT JOIN 8_drreturnsummary drr ON dr.idno = drr.idno
          WHERE mm.status &gt; 0 AND dr.status = 1
          AND dr.ispaid = 'Full Payment'
          AND dr.trandate BETWEEN '".$date1."' AND '".$date2."' 
          AND drr.trandate BETWEEN '".$date1."' AND '".$date2."'";
  </code></pre>
  
  <p><code>SUM(dr.totalamt) as total_amount</code> works fine. The only problem is <code>SUM(drr.totalamt) as return_amount</code></p>