CREATE TABLE diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB)
CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME)
CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME)
CREATE TABLE vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME)
CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER)
CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME)
CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME)
CREATE TABLE patient (uniquepid CLOB, patienthealthsystemstayid NUMBER, patientunitstayid NUMBER, gender CLOB, age CLOB, ethnicity CLOB, hospitalid NUMBER, wardid NUMBER, admissionheight NUMBER, admissionweight NUMBER, dischargeweight NUMBER, hospitaladmittime TIME, hospitaladmitsource CLOB, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus CLOB)
CREATE TABLE intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME)
CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME)

since 2105 what are the top three most frequently ordered lab tests for patients during the same month after being diagnosed with arterial thromboembolism - right upper extremity?
SELECT t3.labname FROM (SELECT t2.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'arterial thromboembolism - right upper extremity' AND STRFTIME('%y', diagnosis.diagnosistime) >= '2105') AS t1 JOIN (SELECT patient.uniquepid, lab.labname, lab.labresulttime FROM lab JOIN patient ON lab.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', lab.labresulttime) >= '2105') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.labresulttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.labresulttime, 'start of month') GROUP BY t2.labname) AS t3 WHERE t3.c1 <= 3
WITH "t2" AS (SELECT "patient"."uniquepid", "lab"."labname", "lab"."labresulttime" FROM "lab" JOIN "patient" ON "lab"."patientunitstayid" = "patient"."patientunitstayid" WHERE STRFTIME('%y', "lab"."labresulttime") >= '2105'), "t3" AS (SELECT "t2"."labname", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS "c1" FROM "diagnosis" JOIN "patient" ON "diagnosis"."patientunitstayid" = "patient"."patientunitstayid" JOIN "t2" "t2" ON "diagnosis"."diagnosistime" < "t2"."labresulttime" AND "patient"."uniquepid" = "t2"."uniquepid" AND DATETIME("diagnosis"."diagnosistime", 'start of month') = DATETIME("t2"."labresulttime", 'start of month') WHERE "diagnosis"."diagnosisname" = 'arterial thromboembolism - right upper extremity' AND STRFTIME('%y', "diagnosis"."diagnosistime") >= '2105' GROUP BY "t2"."labname") SELECT "t3"."labname" FROM "t3" "t3" WHERE "t3"."c1" <= 3