นับจำนวนผู้เสียชีวิตหลังจากได้รับการวินิจฉัยว่าตกเลือดในโรงพยาบาลเดียวกันเมื่อ 1 ปีที่แล้ว ไม่จำเป็นต้องใช้ตารางทั้งหมด
count the number of people that died after being diagnosed with hemorrhage in the same hospital encounter until 1 year ago.It is not neccessary to use all the tables.
 lab:  labid [ number]  patientunitstayid [ number]  labname [ text]  labresult [ number]  labresulttime [ time] 
SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT t1.uniquepid, t1.diagnosistime, t1.patienthealthsystemstayid FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hemorrhage') AS t1 GROUP BY t1.uniquepid HAVING MIN(t1.diagnosistime) = t1.diagnosistime AND DATETIME(t1.diagnosistime) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 JOIN (SELECT patient.uniquepid, patient.patienthealthsystemstayid, patient.hospitaldischargetime FROM patient WHERE patient.hospitaldischargestatus = 'expired') AS t3 ON t2.uniquepid = t3.uniquepid WHERE t2.patienthealthsystemstayid = t3.patienthealthsystemstayid