I am writing an sql query and am stuck on the logic. I am working on a remediation project where I want to apply a historical discount to customers floating or variable Home Loan that can apply at different times.
So the discount on their HL rate maybe 0.5% on their rate (say 4.99%) over a period of time. The trouble is multiple customers (up to 3) can be joined on the HL and each customer can be entitled to discounts at different times.
Lets say a customer has a Home Loan from 2010 to present which is floating. There are 3 customers attached to this Home Loan. Customer 1 has a discount from March 2011 to April 2013. Customer 2 has a discount from April 2012 to April 2015 and customer 3 has a discount from Sep 2018 until present. I'd like to apply the discount to the balance of the Home Loan from March 2011 to April 2015 and then again from Sep 2018 until present. Has anyone encountered this problem before or know of an example online tackling a similar issue that I can base my code off?
Thanks for any help