|
Light -> Incorrect results (10/29/2003 3:23:07)
|
Hi, here is the story: I have 2 tables charge and payment, table charge has student_number field and charges field, payment has student_number field and payment field. I’m using the following code to get the total charges and total payments and the balance. The problem starts when one table has more row than other one in this case total charges or total payments will be two times more! I give you an example: If there is a charge of $1000 and $500 payment the result is: Total payment = 500 Total charge = 1000 Total Balance is 500 Which is ok but if I add an other $1000 charge but no payment the result is: Total payment = 1000 Total charge = 2000 Total Balance is 1000 And so on please have a look and let me know what is wrong! Thanks a lot. <!--#include file="_fpclass/fpdblib.inc"--> <%fp_sQry="SELECT * FROM charge, pay WHERE charge.student_number=pay.student_number" fp_sDefault="" fp_sNoRecords="No records returned." fp_sDataConn="new_page_1" fp_iMaxRecords=256 fp_iCommandType=1 fp_iPageSize=0 fp_fTableFormat=False fp_fMenuFormat=False fp_sMenuChoice="" fp_sMenuValue="" fp_iDisplayCols=3 fp_fCustomQuery=False BOTID=0 fp_iRegion=BOTID %> <%dim mvalue: mvalue=0%> <%dim mvalue1: mvalue1=0%> <%dim mvalue2: mvalue2=0%> <!--#include file="_fpclass/fpdbrgn1.inc"--> <%MValue = MValue + cInt(FP_FieldVal(fp_rs,"payment"))%> <%MValue1 = MValue1 + cInt(FP_FieldVal(fp_rs,"charges"))%> <%MValue2 = MValue1-MValue%> <!--#include file="_fpclass/fpdbrgn2.inc"--> Total payment = <%=MValue%> <br> Total charge = <%=MValue1%> <br> Total Balance is <%=MValue2%> <br>
|
|
|
|