Hi All Experts,
I have a loan table where monthly deduction is made, now some staff loan was not deducted in february i.e '201002', what i want to do now is to move the undeducted loan to the end of the loan period, that is if the staff loan is to finished by may i.e '201005'
it should increament it to june (201006) if it is june it should now be july i.e 201007.
Below is my querry:
SET IDENTITY_INSERT tblDeuloan ON
insert into tblDeuloan (staffid,Period_Month,LoanREf,Capital,Interest, [Status],S_N ,CapitalPaid,InterestPaid,Officer)
select staffid, max(Period_Month)+1,LoanREf,Capital,Interest, 'Active', (convert(BIGINT,S_N)+1) ,0.00,0.00,Officer
WHERE (Period_Month = '201002' and [Status] = 'Active')
GROUP BY staffid,Period_Month,LoanREf,Capital,Interest, [Status],S_N ,CapitalPaid,InterestPaid,Officer
the querry would have worked fine but instead of looking for the max month for each staff, its only adding one month to february for all staff. Please help.
View Complete Post