คำนวณจำนวนผู้ป่วยที่ได้รับยากันชัก - valproate หัตถการ 2 ครั้งในปีที่แล้ว ไม่จำเป็นต้องใช้ตารางทั้งหมด
calculate the number of patients that had received a anticonvulsants - valproate procedure two times the last year.It is not neccessary to use all the tables.
 lab:  labid [ number]  patientunitstayid [ number]  labname [ text]  labresult [ number]  labresulttime [ time] 
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, COUNT(*) AS c1 FROM patient WHERE patient.patientunitstayid = (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'anticonvulsants - valproate' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 = 2