นับจำนวนผู้ป่วยที่ได้รับอินซูลิน - หัตถการแช่ต่อเนื่องในเดือนเดียวกันภายหลังที่ได้รับยาแก้ปวด - หัตถการแก้ปวดยาเสพติดในระหว่างปีนี้ ไม่จำเป็นต้องใช้ตารางทั้งหมด
count the number of patients who received a insulin - continuous infusion procedure during the same month after they received a analgesics - narcotic analgesic procedure during this year.It is not neccessary to use all the tables.
 medication:  medicationid [ number]  patientunitstayid [ number]  drugname [ text]  dosage [ text]  routeadmin [ text]  drugstarttime [ time]  drugstoptime [ time] 
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'analgesics - narcotic analgesic' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'insulin - continuous infusion' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t2 WHERE t1.treatmenttime < t2.treatmenttime AND DATETIME(t1.treatmenttime, 'start of month') = DATETIME(t2.treatmenttime, 'start of month')