Gregorys05
Starting Member
5 Posts |
Posted - 2013-06-20 : 11:12:58
|
Hi all,I have the below queryDECLARE @LoanValue decimal(38,20)DECLARE @APR decimal(20,15)DECLARE @FullTerm intDECLARE @CurrentPeriod intDECLARE @ALAGU decimal(20,15)SET @LoanValue = -20560SET @APR = 0.11 --11%SET @FullTerm = 128 --300 months = 25 yearsSET @CurrentPeriod = 1+1 --For which payment period do you want the payment breakdown?Set @ALAGU = 0.8578 -- Allocated Loan Amount Gross-upDECLARE @PMT decimal(38,2)DECLARE @FV decimal(38,2)DECLARE @IPMT decimal(38,2)DECLARE @PPMT decimal(38,2)Update MASet MA.[Allocated Loan Amount @ Sep-13] = Convert(decimal(38,0),dbo.IPMT(@APR/12.0, @CurrentPeriod, @FullTerm, @LoanValue, 0, 0)/(@APR/12))From dbo.TblMaster MA Which works fine with static values but i want to change the @LoanValue to not be a static value of -20560 but to be the value fromSelect MA.Loanvalue from dbo.tblmaster where MA.Serial = 'Serial from update query' The issue i am having is that the Update query will update of every row within my table but how to do tell the @loanvalue to be the MA.loanvalue that matches the right serial number.E.gSerial - LoanValue - [Allocated Loan Amount @ Sep-13] 1 -2000 Convert(decimal(38,0),dbo.IPMT(@APR/12.0, @CurrentPeriod, @FullTerm, -2000, 0, 0)/(@APR/12)) 2 -5000 Convert(decimal(38,0),dbo.IPMT(@APR/12.0, @CurrentPeriod, @FullTerm, -5000, 0, 0)/(@APR/12)) 3 -3000 Convert(decimal(38,0),dbo.IPMT(@APR/12.0, @CurrentPeriod, @FullTerm, -3000, 0, 0)/(@APR/12)) 4 -4000 Convert(decimal(38,0),dbo.IPMT(@APR/12.0, @CurrentPeriod, @FullTerm, -4000, 0, 0)/(@APR/12))Please help |
|