Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following query will results all loans which are over due either principal amount or interest or charges.


SELECT loan.product_id as loanid, schloan.loanproduct_id as productid, datediff(CURDATE(),sch.principal_amount, sch.interest_amountduedate) as numberofdaysoverdue,
loan.total_outstanding_derived as outstandingbalance, sch.duedate
FROM m_loan_repayment_schedule as sch
LEFT JOIN m_loan as loan
ON sch.loan_id = loan.id
WHERE loan.loan_status_id=300 and sch.principal_amount > 0 AND sch.completed_derived=false and sch.duedate < CURDATE()    
GROUP BY sch.loan_id HAVING sch.duedate=min(sch.duedate)


loanidproductidnumberofdaysoverdueoutstandingbalanceduedate
1198595403.96002013-05-01
131169216300.00002013-10-15
2721141810654.00002011-10-20
322666600.00002015-09-01
3933137584.71002015-08-25