ชื่อยาที่จ่ายให้กับผู้ป่วย 52647 ระหว่างการรักษาในโรงพยาบาลเดียวกัน หลังจากได้รับการวินิจฉัยว่ามีภาวะเม็ดเลือดแดงแทรกซ้อนตั้งแต่ 08/2102 คืออะไร? ไม่จำเป็นที่จะต้องใช้ตารางทั้งหมด
what was the name of the drug being prescribed to patient 52647 during the same hospital encounter after having been diagnosed with hematoma complic proc since 08/2102?It is not neccessary to use all the tables.
 inputevents_cv:  row_id [ number]  subject_id [ number]  hadm_id [ number]  icustay_id [ number]  charttime [ time]  itemid [ number]  amount [ number] 
SELECT t2.drug 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 admissions.subject_id = 52647 AND diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'hematoma complic proc') AND STRFTIME('%y-%m', diagnoses_icd.charttime) >= '2102-08') AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate, admissions.hadm_id FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE admissions.subject_id = 52647 AND STRFTIME('%y-%m', prescriptions.startdate) >= '2102-08') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.startdate AND t1.hadm_id = t2.hadm_id