makeitwork09
Technical User
I am using MS SQL Server 2005
It is possible for each loan to have several installment rows, some of which are future installments. We want to extract the most current installment row. The current piece of code in a view uses the following code, which gets us to where we want to be, but the users would like us to also include the last installment row even if that last row's effective THRU date has passed.
What we currently have is code that reads as:
Code:
The effective FROM date is = to the minimum effective FROM date where the effective THRU date is > the prior month end date
AND
The effective THRU date > the prior month end date
Here is a data sample to help make this make sense (based on the prior month end date being 05/31/2011)
loan eff_from_dte eff_thru_dte
8886357 2006-01-20 2011-01-15 <<<--users want to pick up this row
8886357 2004-07-20 2005-12-20
8886357 1999-07-20 2004-06-20
8886357 1994-07-20 1999-06-20
8880300 2011-01-04 2011-03-04
8880300 2011-04-04 2011-06-04 <<<--users want to pick up this row
8880300 2011-07-04 2012-11-04
8880305 2011-04-10 2012-03-10 <<<--users want to pick up this row
8880305 2012-04-10 2018-03-10
Notice that for 8886357 the last installment ended on 1/15/2011. The user wants to see this row, but the code mentioned above does not include that row. How can I modify the view to pick up that installment row?
Thanks