一种简单的方法用于
ROW_NUMBER()查找每个测试的最新记录:
SELECt pd.PatientID as [Patient ID], pd.PatientName as Name, pd.DateOfBirth as DOB, v.Test as Test, v.Results as Results, v.TestDate as DateFROM PatientDemographic pd JOIN (SELECt v.*, ROW_NUMBER() OVER (PARTITION BY PatientId, Test ORDER BY TestDate DESC) as seqnum FROM Vitals v WHERe v.TestDate BETWEEN '2015-01-01' AND '2015-12-31' AND v.Test LIKE 'BP%' ) v ON pd.PatientID = v.PatientID WHERe seqnum = 1ORDER BY pd.PatientID, v.TestDate;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)