title: Mysql multiple join query record issue
body: <p>Below is my query ,</p>
  
  <pre><code>SELECT 
      u.id, 
      CONCAT(u.FirstName, ' ', u.LastName) as customer, 
      (
          (
              CASE WHEN pmt.TotalCreditedAmt IS NOT NULL THEN pmt.TotalCreditedAmt ELSE 0 END
          ) - (
              CASE WHEN trns.TotalDeductAmt IS NOT NULL THEN trns.TotalDeductAmt ELSE 0 END
          )
      ) as closing_balance 
  FROM 
      (`Users` as u) 
      JOIN `UserAddresses` as uaddresses ON `u`.`Id` = `uaddresses`.`UserId` 
      AND (
          uaddresses.PreferredPickUpAddress = "Yes"
      ) 
      LEFT JOIN (
          SELECT 
              sum(CreditedAmount) AS TotalCreditedAmt, 
              UserId 
          FROM 
              Payment 
          where 
              PaymentSucc = "Yes" 
                      GROUP BY 
              UserId
      ) as pmt ON `pmt`.`UserId` = `u`.`id` 
      LEFT JOIN (
          SELECT 
              sum(Amount) AS TotalDeductAmt, 
              UserId 
          FROM 
              Transaction 
  
          GROUP BY 
              UserId
      ) as trns ON `trns`.`UserId` = `u`.`id` 
  WHERE 
      `u`.`UserType` = 'User' 
      AND `uaddresses`.`PincodeId` IN ('10369', '10372', '10309') 
  ORDER BY 
      `u`.`id` desc 
  </code></pre>
  
  <p>From above query from user address table condition my users table records are 80</p>
  
  <p>from that 80 records in payment table records are 31 and in transaction table entry are 9 with group by query in this tables</p>
  
  <p>from both the tables(payment &amp; transaction) unique users are 34 means some user are in payment and some users are in transaction in result there are total distinct user are 34 from 80 users.</p>
  
  <p>my required result is 34 users but it gives me 80 users</p>
  
  <p>can any one help me to resolve this issue.</p>