I have a table of data that holds admission and discharge dates to multiple residences for multiple individuals. Looks like this:
Unique ID Person ID Program ID Admit Date Discharge date
1 001 9999 1/1/2017 6/1/2017
2 001 5656 6/1/2017 6/25/2017
3 001 9999 6/25/2017 (NULL)
4 002 1212 1/1/2017 6/1/2017
5 002 4444 6/1/2017 7/25/2017
6 002 1212 7/25/2017 (NULL)
Of course there can be multiple records per person per program. What I need to return is the earliest admit date for a person that is currently in a program that does not have a break of more than 30 days. So, in the simple example above I would return the admit date of "1/1/2017" for person 001 in program 9999 and admit date "7/25/2017" for person 002 in program 1212. Any help is appreciated.
Unique ID Person ID Program ID Admit Date Discharge date
1 001 9999 1/1/2017 6/1/2017
2 001 5656 6/1/2017 6/25/2017
3 001 9999 6/25/2017 (NULL)
4 002 1212 1/1/2017 6/1/2017
5 002 4444 6/1/2017 7/25/2017
6 002 1212 7/25/2017 (NULL)
Of course there can be multiple records per person per program. What I need to return is the earliest admit date for a person that is currently in a program that does not have a break of more than 30 days. So, in the simple example above I would return the admit date of "1/1/2017" for person 001 in program 9999 and admit date "7/25/2017" for person 002 in program 1212. Any help is appreciated.