Re: incorrect SUM() results

2003-06-27 Thread Victoria Reznichenko
Shaun Callender [EMAIL PROTECTED] wrote: I'm using mySQL 4.0 trying to solve what I think is a simple problem. to calculate the balance by account # can this be done without the use of temporary tables ? TABLE 1 contains ACCOUNT #, INVOICE #, INV TOTAL TABLE 2 contains there can be

RE: incorrect SUM() results

2003-06-27 Thread csebe
Hi all, -Original Message- From: Victoria Reznichenko [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 3:18 PM To: [EMAIL PROTECTED] Subject: Re: incorrect SUM() results Shaun Callender [EMAIL PROTECTED] wrote: I'm using mySQL 4.0 trying to solve what I think is a simple

Re: incorrect SUM() results

2003-06-27 Thread Bruce Feist
Shaun Callender [EMAIL PROTECTED] wrote: calculate the balance by account # TABLE 1 contains ACCOUNT #, INVOICE #, INV TOTAL TABLE 2 contains there can be multiple payment records associated with an invoice ACCOUNT #, INVOICE #, PAYMENT, PAYMENT DATE select TABLE1.accountno,

Re: incorrect SUM() results

2003-06-27 Thread Chris Tucker
You're running a join on table two which will result in the following set (if you remove the group by and sum()s): ABCCORP 500, 150, 350 (from table 1, row 1, join table 2, row 1) ABCCORP 500, 50, 300 (from table 1, row 1, join table 2, row 2) ABCCORP 500, 50, 250 (from table 1, row 1, join