I hope I can word this so it makes sense and I didn't forget anything.
person_id start_date term class
1 10/23/2012 1128 test
1 05/07/2013 1136 life
1 07/20/2013 1136 life
1 10/07/2014 1148 test
1 01/26/2015 1154 test
2 05/24/2011 1116 life
2 06/20/2015 1156 life
2 11/05/2015 1158 life
3 04/30/2014 1144 life
3 06/11/2015 1156 life
1. I need to look at person_ids where the terms are greater or equal to 1136
2. Take the minimum start date in each term
3. If the previous record's start date is one more than 3 years from that minimum start date then include.
For the above records, these are the person_ids that would be included:
person_id start_date term class
2 05/24/2011 1116 life
2 06/20/2015 1156 life - 1) term is greater or equal to 1136 2) previous record's start date 05/24/2011 is more than 3 years when you minus 3 years from this class's start date 06/20/2015 which is 06/20/2012
2 11/05/2015 1158 life
3 04/30/2014 1144 life - term is greater or equal to 1144 and there are no previous records so include.
3 06/11/2015 1156 life
For the above records, these are the person_ids that would be NOT be included:
1 10/23/2012 1128 test
1 05/07/2013 1136 life- 1) term is greater or equal to 1136 2) minimum start date in this term is 05/07/2013 3) previous record's start date is 10/23/2012 so this is NOT more than 3 years when you minus 3 years from this class's start date 05/07/2013 which is 05/07/2010
1 07/20/2013 1136 life
1 10/07/2014 1148 test
1 01/26/2015 1154 test
If I can't do greater or equal to 1136 in one run then I can do one term at a time. So just look at person_ids in 1136, evaluate if they should be included or not and get results. Run report again but look at person_ids in 1138, evaluate if the should be included or not then get results and so on.....
I'd really appreciate help with this report.
Thanks
person_id start_date term class
1 10/23/2012 1128 test
1 05/07/2013 1136 life
1 07/20/2013 1136 life
1 10/07/2014 1148 test
1 01/26/2015 1154 test
2 05/24/2011 1116 life
2 06/20/2015 1156 life
2 11/05/2015 1158 life
3 04/30/2014 1144 life
3 06/11/2015 1156 life
1. I need to look at person_ids where the terms are greater or equal to 1136
2. Take the minimum start date in each term
3. If the previous record's start date is one more than 3 years from that minimum start date then include.
For the above records, these are the person_ids that would be included:
person_id start_date term class
2 05/24/2011 1116 life
2 06/20/2015 1156 life - 1) term is greater or equal to 1136 2) previous record's start date 05/24/2011 is more than 3 years when you minus 3 years from this class's start date 06/20/2015 which is 06/20/2012
2 11/05/2015 1158 life
3 04/30/2014 1144 life - term is greater or equal to 1144 and there are no previous records so include.
3 06/11/2015 1156 life
For the above records, these are the person_ids that would be NOT be included:
1 10/23/2012 1128 test
1 05/07/2013 1136 life- 1) term is greater or equal to 1136 2) minimum start date in this term is 05/07/2013 3) previous record's start date is 10/23/2012 so this is NOT more than 3 years when you minus 3 years from this class's start date 05/07/2013 which is 05/07/2010
1 07/20/2013 1136 life
1 10/07/2014 1148 test
1 01/26/2015 1154 test
If I can't do greater or equal to 1136 in one run then I can do one term at a time. So just look at person_ids in 1136, evaluate if they should be included or not and get results. Run report again but look at person_ids in 1138, evaluate if the should be included or not then get results and so on.....
I'd really appreciate help with this report.
Thanks