select [Inv ID], [Advance Payment],[Works Certified], [Advance 10%], (SELECT Sum(NZ([Advance Payment],0)-NZ([Works Certified],0)) FROM yourTable WHERE [Inv ID]<=T1.[Inv ID]) As [Advance Payment Balance] FROM YourTable AS T1
Replace YourTable with the correct table name.
Dear Arnel,
Actually, my query already contains the following SQL. How can i integrate the above with that? I have edited your SQL with correct field names and Table name.
SELECT InvoiceMaster.ID,[AdvancePayment],[GrossInv-WorksCertified-61110], [Advance 409130], (SELECT Sum(NZ([AdvancePayment],0)-NZ([GrossInv-WorksCertified-61110],0)) FROM [SubCon-BasicInfo] WHERE [Inv ID]<=T1.[Inv ID]) As [Advance Payment Balance] FROM [SubCon-BasicInfo] AS T1;
Can you please integrate the above code with the below code!!
SELECT InvoiceMaster.ID, InvoiceMaster.SubConName, InvoiceMaster.Phase, InvoiceMaster.InvDate, InvoiceMaster.ReceiptDate, InvoiceMaster.InvNo, InvoiceMaster.ElodieDocNo, InvoiceMaster.Description, InvoiceMaster.PaymentCertiNo, InvoiceMaster.ProgressMonth, InvoiceMaster.ContractType, InvoiceMaster.AdvancePayment, InvoiceMaster.[GrossInv-WorksCertified-61110], InvoiceMaster.PayDueDate, InvoiceMaster.DatePaid, InvoiceMaster.TRANo, InvoiceMaster.Amount, ([GrossInv-WorksCertified-61110]*[SubCon-BasicInfo].[Advance-409130-%]/100) AS [Advance 409130], ([GrossInv-WorksCertified-61110]*[SubCon-BasicInfo].[Retension-401800%]/100) AS [Retension 401800], ([GrossInv-WorksCertified-61110]*[SubCon-BasicInfo].[SafetyRetention-401600%]/100) AS [Safety Retention 401600], ([GrossInv-WorksCertified-61110]*[SubCon-BasicInfo].[Performance-401700%]/100) AS [Performance 401700], Nz([Advance 409130])+Nz([Retension 401800])+Nz([Safety Retention 401600])+Nz([Performance 401700]) AS DeductionsTotal, IIf(([AdvancePayment])>1 And [DeductionsTotal]<0,([AdvancePayment]),Nz([AdvancePayment])+Nz([GrossInv-WorksCertified-61110])-Nz([DeductionsTotal])) AS [Net Payable]
FROM [SubCon-BasicInfo] INNER JOIN InvoiceMaster ON [SubCon-BasicInfo].SubConName = InvoiceMaster.SubConName;