是不是可以这样, 没测试哈 -
select
a.NI
from
PatientAdmissionsData a join PatientAdmissionsData b
on b.NI = a.NI and
b.AdmissionDate > a.AdmissionDate and
b.AdmissionDate < dateadd(m, 2, a.AdmissionDate)
group by
a.NI, a.AdmissionDate
having
count(*) > 5
[
本帖最后由 png 于 2012-6-7 11:37 编辑 ]