title: Getting a SUM of the values in INNER JOIN adds up duplicate values
body: <p>I am running a query which is counting the records on monthly basis from the table. 
  I am trying to add one extra column called "TotalPrice", I need a sum of all the prices from 'settle' table.</p>
  
  <p>The problem I am facing is because of INNER JOIN, 'SUM' of the prices is adding up multiple prices due to duplicate records which the INNER JOIN is returning. Is there a way to avoid it and get a SUM of the prices from unique records ?</p>
  
  <pre><code>SELECT
  CONCAT(year(datetime), '-', month(datetime)) AS YearMonth,
  COUNT (DISTINCT a.id) AS TOTAL, SUM(total_price) AS TotalPrice
  FROM settle AS a with (nolock)
       INNER JOIN transfers b with (nolock) ON b.settleId = a.id 
       INNER JOIN Fdata AS c with (nolock) ON c.id=  b.data 
  GROUP BY CONCAT(year(datetime), '-', month(datetime))
  </code></pre>
  
  <p>Thanks in advance.</p>