MySQL Forums
Forum List  »  Newbie

Re: Determine Balance Due from Two Tables
Posted by: Courtney Marton
Date: June 30, 2005 02:39PM

I believe that this query should work:

select r.clientid,r.name,
totalcost,totalpaid,totalcost-totalpaid
from
(select sum(tblregistration.amount) as totalcost
from tblregistration,tblclient
where tblregistration.clientid = tblclient.clientid
group by tblregistration.clientid) as r,

(select sum(tblpayment.amount) as totalpaid
from tblpayment
group by tblpayment.clientid) as p

where r.clientid = p.clientid

Unfortunately my web host is running version 4.0.23 and, thus, I cannot use this nested select. Is there a workaround?

Thanks!
Courtney

Options: ReplyQuote


Subject
Written By
Posted
Re: Determine Balance Due from Two Tables
June 30, 2005 02:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.