นับจำนวนผู้ป่วยที่เสียชีวิตหลังจากได้รับการวินิจฉัยว่ามีอาการเพ้อในการไปโรงพยาบาลครั้งเดียวกันในปีนี้ ไม่จำเป็นต้องใช้ตารางทั้งหมด
count the number of patients who are dead after being diagnosed with delirium within the same hospital visit in this year.It is not neccessary to use all the tables.
 vitalperiodic:  vitalperiodicid [ number]  patientunitstayid [ number]  temperature [ number]  sao2 [ number]  heartrate [ number]  respiration [ number]  systemicsystolic [ number]  systemicdiastolic [ number]  systemicmean [ number]  observationtime [ 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 = 'delirium') AS t1 GROUP BY t1.uniquepid HAVING MIN(t1.diagnosistime) = t1.diagnosistime AND DATETIME(t1.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 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