hi All,
I have two tables
table-1:customeramount
table-2:customerpurchaseamount
table1 have customers bonus amount and table 2 i have customers purchase amount now i need to calculate balance bonus amount i tried with following query but It shows unexpected result , could any one guide me..
SELECT CM.`custid`,
SUM(CM.`amount`) - SUM(CP.`Amount`) as balance
FROM
`customeramount` as CM JOIN customerpurchaseamount as CP
ON
CM.`custid`= CP.`CustomerID`
GROUP BY CM.`custid`