We are on MS SQL-Server 2012.Users want to know if the time of the patients next admission date is less than 30 days for any reason. Doesn’t have to be seen by same provider
I am not sure how to read the next record, if the MRN ID is the same, then calculate the difference in days between the record you are on and the next next record.
For example:
Record 1 : MRNID =33 Discharge date = 1/1/2016
Record 2 : MRNID = 33 Admission date = 2/2/2016
MRNIDs are the same, so I calculate. Then I compare record 2 to record 3 and do the same process.
1条答案
按热度按时间h6my8fg21#
Use Lead() window function
SAMPLE OUTPUT