คำนวณจำนวนผู้เสียชีวิตหลังจากได้รับการวินิจฉัยว่าเป็นโรคหลอดอาหาร varice oth dis nos ในการมาโรงพยาบาลครั้งเดียวกันตั้งแต่ 1 ปีที่แล้ว ไม่จำเป็นต้องใช้ตารางทั้งหมด
calculate the number of people who died after being diagnosed with esoph varice oth dis nos within the same hospital visit since 1 year ago.It is not neccessary to use all the tables.
 d_items:  row_id [ number]  itemid [ number]  label [ text]  linksto [ text] 
SELECT COUNT(DISTINCT t2.subject_id) FROM (SELECT t1.subject_id, t1.charttime, t1.hadm_id FROM (SELECT admissions.subject_id, diagnoses_icd.charttime, admissions.hadm_id FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'esoph varice oth dis nos')) AS t1 GROUP BY t1.subject_id HAVING MIN(t1.charttime) = t1.charttime AND DATETIME(t1.charttime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 JOIN (SELECT patients.subject_id, admissions.hadm_id, patients.dod FROM admissions JOIN patients ON patients.subject_id = admissions.subject_id WHERE NOT patients.dod IS NULL AND DATETIME(patients.dod) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t3 ON t2.subject_id = t3.subject_id WHERE t2.hadm_id = t3.hadm_id