lcAcctID = STR(tiAcctID) ... SELECT t.iID, t.iNo, t.dDt, s.bDrAmt - uf.bDr + ut.bCr, s.bCrAmt - uf.bCr + ut.bDr FROM tAccountsJV t JOIN sAccountsJV s ON t.iID = s.iPID AND s.iAcctID = ?lcAcctID JOIN uAdjustments uf ON uf.iPID = s.iPID JOIN uAdjustments ut ON ut.iSID = s.iPIDYou would store info in two records (one FROM and anothe TO account) in tAccountsJV if it was normalized.
SQLExec(THISFORM.nConnHnd, ; > [SELECT t.iID, t.iNo, ] ; > + [t.dDt, s.bDrAmt, s.bCrAmt FROM tAccountsJV t, sAccountsJV s ] ; > + [WHERE t.iID = s.iPID AND s.iAcctID = ] + STR(tiAcctID), ; > [curtAccountsJV]) >brow norm>
>151 1 01/04/2004 100.00 0.00 >165 2 05/04/2004 0.00 60.00>
>151 1 01/04/2004 40.00 0.00 >165 2 05/04/2004 0.00 0.00>
>iID Integer PK >iNo Integer Document Sr. No. >dDt Date Document Date>
>151 1 01/04/2004 >165 2 05/04/2004>
>iID Integer PK >iPID Integer FK >iAcctID Integer Account code >bDrAmt Double Debit Amt. >bCrAmt Double Credit Amt.>
>1145 151 555 100.00 0.00 >1146 151 8 0.00 100.00 >1155 165 45 100.00 0.00 >1156 165 555 0.00 60.00>
>iId Integer PK >iPID Integer FK >iSID Integer Reference field >iAcctId Integer Account code >bDr Double Debit Amt. Adjusted >bCr Double Credit Amt. Adjusted>
>1234 165 151 555 0.00 60.00
>