Date Company Name Amount 2013-12-11 smevc 500 2013-12-21 smevc 500 2013-12-21 smevc 1000 2013-12-21 smevc 6726 2013-12-21 smevc 8354.40 2013-12-20 smevc 700 2013-12-22 sec 3736 2013-12-23 ccs 3000
Date company_name deb_amt 2013-12-24 smevc 1000 2013-12-22 smevc 2000 2013-12-22 sec 736 2013-12-22 ccs 2000
comp_name bal_amt smevc 14780.40 sec 3000 ccs 1000
SELECT cm.`Company Name` AS comp_name, ((SELECT SUM(Amount) FROM credit c WHERE c.`Company Name` = cm.`Company Name` GROUP BY c.`Company Name`) - (SELECT SUM(deb_amt) FROM debit d WHERE d.company_name = cm.`Company Name` GROUP BY d.company_name)) AS bal_amt FROM credit cm GROUP BY cm.`Company Name` ORDER BY bal_amt DESC
SELECT * ,val-amountval FROM (select *, sum(`Amount`) val from credit group by CompanyName) as c left join (select Company_Name, sum(amount) amountval from debit group by Company_Name) as d on c.comname=d.comname
SELECT C.[Company Name] AS COMPNAME, SUM(C.Amount) AS AMT, SUM(D.DEB_AMT) AS DEBIT, SUM(C.Amount) - SUM(D.DEB_AMT) AS BALANCE FROM Credit AS C INNER JOIN Debit AS D ON C.[Company Name] = D.[Company Name] GROUP BY C.[Company Name]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)