Madhan M

Madhan M

  • NA
  • 95
  • 3.5k

Loan balance details All Employee Example here

Jun 8 2017 5:49 AM


select distinct E.C_Employeecode,E.F_Loan_Amt as Total_Amt,
E.F_No_Of_Installment as Total_Inst,
ISNULL(SUM(R.F_Amount),0) AS 'PAID AMT',
E.F_Loan_Amt-ISNULL(SUM(R.F_Amount),0) As 'Balance_Amt',
CEILING((E.F_No_Of_Installment-ISNULL(SUM(R.F_Amount),0))/(R.InstAmt*1.))'Balance.Instal'
From
(
select C_EmployeeCode,C_LoanCode,Sum(F_Amount)F_Amount,MAX(F_Amount)as InstAmt
from Loan_recovery where C_Employeecode='50173' GROUP BY C_Employeecode,C_LoanCode
) R

LEFT JOIN LoanAvail_Entry E on R.C_Employeecode=E.C_Employeecode and E.C_Employeecode='50173'
GROUP BY E.C_Employeecode,InstAmt,E.F_No_Of_Installment,E.F_Loan_Amt

Answers (1)