ok, here is the deal:
I have 2 tables: invoice & payments.
the invoice include all information the customer needs to pay (hotel, flights...) the payments shows all payments done by him.
So.... I am trying to get the SUM of all the invoice AND the SUM of all payments.
it works...but not correctly. It if there are 5 arguments in the deposit and one payment it multiply the deposit 5 times (the amount of argumetns in the invoice).
My statment is this:
SELECT invoice.Customer_ID,
SUM( (perCustomer)* (timesCustomer)) as TotalInvoice,
SUM( paymentAmount) as TotalPayments,
( SUM(perCustomer)* SUM(timesCustomer)-SUM(paymentAmount) ) as Balance
FROM invoice, payment
WHERE invoice.Customer_ID = payment.Customer_ID
GROUP BY Customer_ID
any idea???
thanks
Peter
[Bear edit: improved title]
[ April 07, 2005: Message edited by: Bear Bibeault ]
I have 2 tables: invoice & payments.
the invoice include all information the customer needs to pay (hotel, flights...) the payments shows all payments done by him.
So.... I am trying to get the SUM of all the invoice AND the SUM of all payments.
it works...but not correctly. It if there are 5 arguments in the deposit and one payment it multiply the deposit 5 times (the amount of argumetns in the invoice).
My statment is this:
SELECT invoice.Customer_ID,
SUM( (perCustomer)* (timesCustomer)) as TotalInvoice,
SUM( paymentAmount) as TotalPayments,
( SUM(perCustomer)* SUM(timesCustomer)-SUM(paymentAmount) ) as Balance
FROM invoice, payment
WHERE invoice.Customer_ID = payment.Customer_ID
GROUP BY Customer_ID
any idea???
thanks
Peter
[Bear edit: improved title]
[ April 07, 2005: Message edited by: Bear Bibeault ]