dwain.c (2/24/2015)
There's a loan amortization example here: Exploring Recursive CTEs by Example[/url]It won't be as fast as a QU approach, but the example does handle multiple loans and if I recall correctly it also handles the final penny rounding.
So I finally had a chance to test your rCTE method and had a few notes. Again, just like with the items I mentioned related to Greg's method, I am not being negative and this doesn't take anything away from what is clearly an excellent article.
CASE PaymentNo + 1 WHEN Period THEN
Types don't match between the anchor and the recursive part in column "Balance" of recursive query "Payments".
I hope this helps. Take care,
Solomon...
SQL# — https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
Sql Quantum Lift — https://SqlQuantumLift.com/ ( company )
Sql Quantum Leap — https://SqlQuantumLeap.com/ ( blog )
Info sites — Collations • Module Signing • SQLCLR