instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: what is the earliest departure time from BOSTON to DENVER ### Response:
SELECT DISTINCT flight.departure_time FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'D...
### Instruction: count the number of patients who received arterial catheterization within 2 months after a diagnosis of malfunc cardiac pacemake since 3 years ago. ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, diagnoses_icd.charttime 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 = 'malfunc cardiac pa...
### Instruction: please find the earliest possible flight from BOSTON to DENVER ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER...
### Instruction: is patient 31615's arterial bp [diastolic] second measured on the last intensive care unit visit greater than the first value measured on the last intensive care unit visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31615) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND chartevents...
### Instruction: until 2 years ago, how many patients underwent fiber-optic bronchoscopy within the same month after they were diagnosed with iatrogenc hypotnsion nec? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, diagnoses_icd.charttime 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 = 'iatrogenc hypotnsi...
### Instruction: what are the three most commonly given lab tests for patients who were diagnosed with reg enteritis, sm intest previously within 2 months, until 2 years ago? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t3.itemid FROM (SELECT t2.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, diagnoses_icd.charttime FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id WHERE diagnoses_icd.i...
### Instruction: For the Fall or Winter term , can I take 400 -level classes ? ### Response:
SELECT DISTINCT COURSEalias0.department, COURSEalias0.name, COURSEalias0.number, SEMESTERalias0.semester FROM (SELECT course_id FROM student_record WHERE earn_credit = 'Y' AND student_id = 1) AS DERIVED_TABLEalias0, course AS COURSEalias0, course_offering AS COURSE_OFFERINGalias0, semester AS SEMESTERalias0 WHERE ((SEM...
### Instruction: what are the three most frequently ordered microbiology tests for patients who have had destruct chest wall les before in the same month last year? ### Response:
SELECT t3.spec_type_desc FROM (SELECT t2.spec_type_desc, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FR...
### Instruction: what was the name of the drug that was prescribed to patient 005-73237 during the same day after having had a enteral feeds - nutritional supplement procedure in a month before? ### Response:
SELECT t2.drugname FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-73237') AND treatment.treatme...
### Instruction: how many patients were diagnosed with urin tract infection nos in 2105 after having previously been diagnosed with sec malig neo sm bowel within 2 months? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, diagnoses_icd.charttime 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 = 'urin tract infecti...
### Instruction: what are the five most frequently prescribed drugs for patients that had previously received closed bronchial biopsy within 2 months, during the previous year? ### Response:
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures ...
### Instruction: what is the name of drug that patient 005-48105 was prescribed for during the same day after having been diagnosed with metabolic acidosis - lactic acidosis since 12/2105? ### Response:
SELECT t2.drugname FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-48105') AND diagnosis.diagnos...
### Instruction: all flights from PITTSBURGH to DALLAS round trip after 12pm less than 100 ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare AS FARE_0, fare AS FARE_1, flight, flight_fare AS FLIGHT_FARE_0, flight_fare AS FLIGHT_FARE_1 WHERE ((FARE_1.round_trip_cost < 100 AND FLIGHT_FARE_1.fare_id = FARE_1.far...
### Instruction: count the number of patients who have received a kidney transplant nec procedure within 2 months after receiving a dx ultrasound-heart treatment until 2 years ago. ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'dx ultrasou...
### Instruction: how many patients received inj/inf platelet inhibit during the same hospital visit following the diagnosis of subclavian steal syndrom since 3 years ago? ### Response:
SELECT COUNT(DISTINCT t1.subject_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 =...
### Instruction: what are patient 14502's changes in arterial bp mean last measured on the last intensive care unit visit compared to the second to last value measured on the last intensive care unit visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14502) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND chartevents...
### Instruction: arterial bp [systolic] for patient 22449 last measured on the last icu visit is greater than the value first measured on the last icu visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22449) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND chartevents...
### Instruction: what were the three most common lab tests that patients were given in the same hospital encounter after being diagnosed with dmii circ nt st uncntrld in 2101? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t3.itemid FROM (SELECT t2.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, diagnoses_icd.charttime, admissions.hadm_id FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id W...
### Instruction: how much is the variation of weight in patient 24921 measured at 2104-09-26 01:00:00 compared to the value measured at 2104-09-24 17:00:00? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 24921)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'a...
### Instruction: i would like a flight that leaves on friday from PHILADELPHIA to DALLAS that makes a stop in ATLANTA ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, airport_service AS AIRPORT_SERVICE_2, city AS CITY_0, city AS CITY_1, city AS CITY_2, date_day, days, flight, flight_stop WHERE ((CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'ATLAN...
### Instruction: until 1 year ago what were the four most commonly ordered laboratory tests for patients who had received non-invasive mech vent previously in the same hospital visit? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t3.itemid FROM (SELECT t2.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime, admissions.hadm_id FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_i...
### Instruction: in 2101 how many people underwent opn rt hemicolectomy nec during the same hospital visit after the first procedure of hepatic duct-gi anastom? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, procedures_icd.charttime, admissions.hadm_id FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_...
### Instruction: MSE rate of posting (checks and dates). ### Response:
SELECT p.Id AS "post_link", p.OwnerUserId AS "user_link", p.CreationDate FROM Posts AS p WHERE p.PostTypeId = 1 AND p.OwnerUserId IN (141525, 146126, 811, 50049, 1438, 164200, 115866, 155160, 98786, 209637, 147336, 131182, 135201, 23354, 51, 6212, 146719, 166017, 4, 2, 130213, 159928, 13, 176330, 208518, 142481, 229741...
### Instruction: what are the top five most frequent laboratory tests that followed in the same month for patients who took ven cath renal dialysis until 2 years ago? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t3.itemid FROM (SELECT t2.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_i...
### Instruction: what were the three procedures most frequently given for patients who had previously been diagnosed with disc dis nec/nos-lumbar within 2 months? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t3.icd9_code FROM (SELECT t2.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, diagnoses_icd.charttime FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissi...
### Instruction: since 2105 what are the four most common specimen test given to patients in the same month after being diagnosed with candidias urogenital nec? ### Response:
SELECT t3.spec_type_desc FROM (SELECT t2.spec_type_desc, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, diagnoses_icd.charttime 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_...
### Instruction: what was the four most frequent drugs that were prescribed within the same hospital visit to a drug withdrawal syndrome - alcohol female patient of age 40s after having been diagnosed with drug withdrawal syndrome - alcohol, until 2102? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'drug withdrawal...
### Instruction: what are the five most frequently prescribed drugs within 2 months to the acute respiratory failure male patients aged 30s after they have been diagnosed with acute respiratory failure since 2 years ago? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, 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 = 'acute respiratory failure' AND DATETIME(diagnosis....
### Instruction: what was the name of the prescription drug patient 012-85821 was prescribed during the same day after having received a vte prophylaxis - coumadin procedure in 04/2102? ### Response:
SELECT t2.drugname FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-85821') AND treatment.treatme...
### Instruction: please list all of the flights leaving ATLANTA heading to BALTIMORE after 2000 wednesday and before 900 thursday ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 24 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time...
### Instruction: in 2104, what were the five most frequent drugs prescribed within 2 months to the hypotension / pressor dependent female patients aged 40s after they had been diagnosed with hypotension / pressor dependent? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, 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 = 'hypotension / pressor dependent' AND STRFTIME('%y'...
### Instruction: Programming languages trends - inc. related tags. ### Response:
SELECT YEAR(p.CreationDate), 100.0 * SUM(CASE WHEN t.Id IN (5, 21, 382, 75151, 3988, 57799, 106940, 114990, 8945, 8279, 14642, 984, 1581, 92312, 1661, 3437, 104777, 60676, 105840, 7528, 112569, 120888, 357, 78546, 26762, 3262, 63960, 98900, 99724, 2290, 66821, 1380, 81001, 5505, 107832, 85709, 2857, 72364, 44230, 38663...
### Instruction: give me information on flights from ATLANTA to WASHINGTON on wednesday after 1600 and thursday before 900 ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 24 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time...
### Instruction: what are the three most commonly prescribed medications for patients who have received audiological evaluation before during the same month, during this year? ### Response:
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures ...
### Instruction: what difference was in the weight of patient 27739 last measured on the last hospital visit compared to the value second to last measured on the last hospital visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27739 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)) AND ch...
### Instruction: are heart rate of patient 2518 measured at 2105-12-31 12:00:00 less than measured at 2105-12-31 09:00:00? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2518)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'he...
### Instruction: how much does the arterial bp [systolic] of patient 8116 vary second measured on the current intensive care unit visit compared to the first value measured on the current intensive care unit visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8116) AND icustays.outtime IS NULL) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_it...
### Instruction: what are the top five commonly prescribed drugs that patients were prescribed after having received a tracheostomy - performed during current admission for ventilatory support treatment during this year within 2 months? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'tracheostomy - performed during current admission ...
### Instruction: what is the number of patients who died after diagnosis of atriovent block-1st degr in the same month during this year? ### Response:
SELECT COUNT(DISTINCT t2.subject_id) FROM (SELECT t1.subject_id, t1.charttime FROM (SELECT admissions.subject_id, diagnoses_icd.charttime 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_di...
### Instruction: what is the four most frequent laboratory test that patients had during the same month after they received a lingual thyroid excision procedure in 2105? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t3.itemid FROM (SELECT t2.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_i...
### Instruction: what are the top five most frequent lab tests that followed within 2 months for the patient who received normal saline administration - moderate volume resuscitation (150-250 mls/hr) in the last year? ### Response:
SELECT t3.labname FROM (SELECT t2.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'normal saline administration - moderate volume resus...
### Instruction: number of active users per month. ### Response:
SELECT Months, (CASE WHEN n_posts > 5 THEN 'n>5' WHEN n_posts > 1 THEN '5>=n>1' ELSE 'n=1' END), COUNT(n_posts) FROM (SELECT COUNT(Id) AS n_posts, 1.000 * TIME_TO_STR(CreationDate, '%Y') + 1.000 * TIME_TO_STR(CreationDate, '%m') / 12 - 1.000 / 24 AS Months, OwnerUserId FROM Posts WHERE PostTypeId IN (1, 2) AND (1.000 *...
### Instruction: show me the five year survival probability of patients who were prescribed clonidine hcl 0.1 mg po tabs after having been diagnosed with s/p breast biopsy? ### Response:
SELECT SUM(CASE WHEN patient.hospitaldischargestatus = 'alive' THEN 1 WHEN STRFTIME('%j', patient.hospitaldischargetime) - STRFTIME('%j', t4.diagnosistime) > 5 * 365 THEN 1 ELSE 0 END) * 100 / COUNT(*) FROM (SELECT t2.uniquepid, t2.diagnosistime FROM (SELECT t1.uniquepid, t1.diagnosistime FROM (SELECT patient.uniquepid...
### Instruction: calculate the five year survival rate among the patients who were prescribed with pantoprazole sod after having been diagnosed with pericardial tamponade - by echocardiogram. ### Response:
SELECT SUM(CASE WHEN patient.hospitaldischargestatus = 'alive' THEN 1 WHEN STRFTIME('%j', patient.hospitaldischargetime) - STRFTIME('%j', t4.diagnosistime) > 5 * 365 THEN 1 ELSE 0 END) * 100 / COUNT(*) FROM (SELECT t2.uniquepid, t2.diagnosistime FROM (SELECT t1.uniquepid, t1.diagnosistime FROM (SELECT patient.uniquepid...
### Instruction: what's the name of the drug patient 52898 was prescribed with during the same hospital visit after having been diagnosed with defibrination syndrome in this month? ### Response:
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 = 52898 AND diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.s...
### Instruction: Can I enroll in 500 -level classes for the Spring or Summer term ? ### Response:
SELECT DISTINCT COURSEalias0.department, COURSEalias0.name, COURSEalias0.number, SEMESTERalias0.semester FROM (SELECT course_id FROM student_record WHERE earn_credit = 'Y' AND student_id = 1) AS DERIVED_TABLEalias0, course AS COURSEalias0, course_offering AS COURSE_OFFERINGalias0, semester AS SEMESTERalias0 WHERE COURS...
### Instruction: what was the top five most frequent drugs that patients were prescribed in the same hospital visit after having been prescribed sertraline hcl 50 mg po tabs in this year? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, medication.drugstarttime, patient.patienthealthsystemstayid FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'sertraline hcl 5...
### Instruction: among patients who received exc/dest hrt lesion open , what are the top four most frequent diagnoses that followed afterwards during the same hospital visit? ### Response:
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t3.icd9_code FROM (SELECT t2.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime, admissions.hadm_id FROM procedures_icd JOIN admissions ON procedures_i...
### Instruction: what are the three most common procedures for a patient who was diagnosed with osteomyelitis nos-pelvis previously within the same hospital visit? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t3.icd9_code FROM (SELECT t2.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, diagnoses_icd.charttime, admissions.hadm_id FROM diagnoses_icd JOIN admissions ON diagnoses_i...
### Instruction: is the heart rate of patient 25300 last measured on the first icu visit less than second to last measured on the first icu visit. ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25300) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND chartevents.item...
### Instruction: what is the change in weight of patient 21454 second measured on the first hospital visit compared to the value first measured on the first hospital visit. ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 21454 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)) AND chartev...
### Instruction: Can I take 300 -level classes in the Spring or Summer term ? ### Response:
SELECT DISTINCT COURSEalias0.department, COURSEalias0.name, COURSEalias0.number, SEMESTERalias0.semester FROM (SELECT course_id FROM student_record WHERE earn_credit = 'Y' AND student_id = 1) AS DERIVED_TABLEalias0, course AS COURSEalias0, course_offering AS COURSE_OFFERINGalias0, semester AS SEMESTERalias0 WHERE COURS...
### Instruction: what was the name of the prescription drug that patient 002-8416 was prescribed during the same day after being diagnosed with s/p thoracotomy in the first hospital visit? ### Response:
SELECT t2.drugname FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-8416' AND NOT patient.hospita...
### Instruction: Numbers most used in posts. totally useless. more of an experiment. ### Response:
SELECT OwnerUserId AS "user_link", OwnerUserId, SUM(LENGTH(Body)) AS totalLen, SUM(LENGTH(Body) - LENGTH(REPLACE(LOWER(Body), '1', ''))) AS "1", SUM(LENGTH(Body) - LENGTH(REPLACE(LOWER(Body), '2', ''))) AS "2", SUM(LENGTH(Body) - LENGTH(REPLACE(LOWER(Body), '3', ''))) AS "3", SUM(LENGTH(Body) - LENGTH(REPLACE(LOWER(Bod...
### Instruction: what are the five most frequently ordered procedures for patients that have previously been diagnosed with splenic trauma - with hematoma within 2 months in a year before? ### Response:
SELECT t3.treatmentname FROM (SELECT t2.treatmentname, 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 = 'splenic trauma - with hematoma' AND DATE...
### Instruction: what are the top four most common medications that followed within 2 months for patients who were diagnosed with atriovent block complete since 2103? ### Response:
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, diagnoses_icd.charttime 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 ...
### Instruction: what is the four most frequent drugs that were prescribed during the same hospital encounter to failure to wean female patients of age 40s after they have been diagnosed with failure to wean since 2104? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'failure to wean...
### Instruction: what is the three most frequently given diagnoses a year before for patients who have previously been diagnosed with atelectasis/collapse within 2 months? ### Response:
SELECT t3.diagnosisname FROM (SELECT t2.diagnosisname, 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 = 'atelectasis/collapse' AND DATETIME(diagn...
### Instruction: patient 594's temperature c (calc) second measured on the first icu visit is less than first measured on the first icu visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 594) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND chartevents.itemid...
### Instruction: the arterial bp [systolic] of patient 12775 last measured on the current intensive care unit visit is greater than the value first measured on the current intensive care unit visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12775) AND icustays.outtime IS NULL) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_i...
### Instruction: what the difference is in weight of patient 23070 last measured on the last hospital visit compared to the value first measured on the last hospital visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23070 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)) AND ch...
### Instruction: in this year what were the top four most frequent diagnoses that patients were given in the same hospital encounter after being diagnosed with anuria - suspect atn? ### Response:
SELECT t3.diagnosisname FROM (SELECT t2.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'anuri...
### Instruction: what 's the schedule of flights from ATLANTA to BOSTON on 8 1 ### Response:
SELECT DISTINCT FLIGHT_0.arrival_time, FLIGHT_0.departure_time FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight AS FLIGHT_0, flight AS FLIGHT_1, flight_leg WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = ...
### Instruction: what's the top four diagnosis that had the highest two year mortality rate? ### Response:
SELECT t4.diagnosisname FROM (SELECT t3.diagnosisname, DENSE_RANK() OVER (ORDER BY t3.c1 DESC) AS c2 FROM (SELECT t2.diagnosisname, 100 - SUM(CASE WHEN patient.hospitaldischargestatus = 'alive' THEN 1 WHEN STRFTIME('%j', patient.hospitaldischargetime) - STRFTIME('%j', t2.diagnosistime) > 2 * 365 THEN 1 ELSE 0 END) * 10...
### Instruction: what drug was prescribed to patient 65582 within 2 days after having undergone the pancreat sphincteroplas since 02/2105? ### Response:
SELECT t2.drug FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE admissions.subject_id = 65582 AND procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = ...
### Instruction: what were the four most frequently ordered specimen tests for patients who were previously diagnosed with anemia - iron deficiency anemia secondary to chronic blood in 2105 within the same hospital visit? ### Response:
SELECT t3.culturesite FROM (SELECT t2.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'anemia - ...
### Instruction: this year, what are the top five most frequent microbiology tests ordered for patients within the same hospital visit after receiving the physical restraints? ### Response:
SELECT t3.culturesite FROM (SELECT t2.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'physical ...
### Instruction: what are the three most frequently prescribed drugs for patients that had previously received vaccination nec within 2 months, until 2101? ### Response:
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures ...
### Instruction: what are the three commonly prescribed drugs that patients aged 60 or above were prescribed within 2 months after they have been diagnosed with post neurointerventional procedure - embolization in 2105? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, 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 = 'post neurointerventional procedure - embolization'...
### Instruction: give me the meal flights departing early saturday morning from CHICAGO to SEATTLE nonstop ### Response:
SELECT DISTINCT flight_id FROM flight WHERE (((((flight_days IN (SELECT DAYSalias0.days_code FROM days AS DAYSalias0 WHERE DAYSalias0.day_name IN (SELECT DATE_DAYalias0.day_name FROM date_day AS DATE_DAYalias0 WHERE DATE_DAYalias0.day_number = 26 AND DATE_DAYalias0.month_number = 7 AND DATE_DAYalias0.year = 1991)) AND ...
### Instruction: count the numbers of patients who were prescribed latanoprost 0.005% ophth. soln. within 2 months after having been diagnosed with swelling of limb since 2103. ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, diagnoses_icd.charttime 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 = 'swelling of limb')...
### Instruction: what are the five most commonly given diagnoses for patients who have previously received parenteral feeds - tpn in the same hospital encounter a year before? ### Response:
SELECT t3.diagnosisname FROM (SELECT t2.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'paren...
### Instruction: list the top five most common drugs that patients were prescribed within 2 months after being prescribed lactated ringers iv solp a year before. ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'lactated ringers iv solp' AND DATETIME(medication.d...
### Instruction: what were the top five most frequent specimen tests that followed in the same hospital visit for patients who were diagnosed with bacteremia - gram negative rod since 5 years ago? ### Response:
SELECT t3.culturesite FROM (SELECT t2.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'bacteremi...
### Instruction: until 3 years ago what were the three most frequent specimen test given to the patients within 2 months after being diagnosed with sepsis - severe? ### Response:
SELECT t3.culturesite FROM (SELECT t2.culturesite, 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 = 'sepsis - severe' AND DATETIME(diagnosis.diag...
### Instruction: count the number of patients who were prescribed sw during the same hospital visit after being diagnosed with hx-lymphatic malign nec in a year before. ### Response:
SELECT COUNT(DISTINCT t1.subject_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 =...
### Instruction: for patients who were diagnosed until 3 years ago with hypoxemia, what were the top four most frequent specimen tests that followed within 2 months? ### Response:
SELECT t3.culturesite FROM (SELECT t2.culturesite, 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 = 'hypoxemia' AND DATETIME(diagnosis.diagnosist...
### Instruction: what are the three most frequently prescribed drugs for patients who have previously been diagnosed with drug withdrawal syndrome - alcohol during the same month, this year? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, 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 = 'drug withdrawal syndrome - alcohol' AND DATETIME(d...
### Instruction: give me the difference between the total of the input and the output of patient 027-144847 on last month/27. ### Response:
SELECT (SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-144847')) AND intakeoutput.cellpath ...
### Instruction: i would like to find a flight from CHARLOTTE NORTH CAROLINA to LAS VEGAS i would like a stopover in ST. LOUIS ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, airport_service AS AIRPORT_SERVICE_2, city AS CITY_0, city AS CITY_1, city AS CITY_2, flight, flight_stop, state WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'LAS VEGAS' AND ...
### Instruction: what were the four most frequently ordered laboratory tests for patients who had been diagnosed with respiratory acidosis - acute previously within 2 months, in this year? ### Response:
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 = 'respiratory acidosis - acute' AND DATETIME(diagnosis...
### Instruction: what was the name of the medication prescribed to patient 006-143187 within 2 days after being diagnosed in their current hospital visit with hypermagnesemia? ### Response:
SELECT t2.drugname FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-143187' AND patient.hospitald...
### Instruction: what are the three most commonly prescribed drugs since 2105 for patients who had serum transfusion nec before during the same month? ### Response:
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures ...
### Instruction: how many patients were prescribed benzocaine 20% spray within 2 months after they had undergone a reopen thoracotomy site, until 2 years ago? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'reopen thor...
### Instruction: Votes cast vs post year. ### Response:
WITH posts_agg AS (SELECT YEAR(CreationDate) AS y, COUNT(*) AS c FROM Posts WHERE PostTypeId IN (1, 2) AND OwnerUserId = 635608 GROUP BY YEAR(CreationDate)) SELECT Post_year AS "Post year", Posts_that_year AS "Posts that year", '2008', '2009', '2010', '2011', '2012', '2013', '2014' FROM (SELECT YEAR(v.CreationDate) AS ...
### Instruction: what were the five most commonly performed microbiology tests for patients who had previously received digoxin in the same month, the previous year? ### Response:
SELECT t3.culturesite FROM (SELECT t2.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'digoxin' AND DATETIME(treatment.treatmenttim...
### Instruction: Attempt to flush out Users part of a voting ring. Targeting the Multi-votes per post in even fashion pattern. My first attempt to flush out Users part of a voting ring. Targeting the Multi-votes per post in even fashion pattern. ### Response:
SELECT vdv.USER_ID AS "user_link", CAST(TIME_TO_STR(vdv.VOTE_DATE, '%b %d, %Y') AS TEXT(20)) AS "date_of_occurence", vdv.VOTE_COUNT AS "votes_per_post", COUNT(vdv.POST_ID) AS "posts_upvoted" FROM (SELECT COUNT(v.Id) AS VOTE_COUNT, p.Id AS POST_ID, p.OwnerUserId AS USER_ID, v.CreationDate AS VOTE_DATE FROM Votes AS v IN...
### Instruction: i need a flight from LONG BEACH to ST. LOUIS stopping in DALLAS the flight should also serve LUNCH ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, airport_service AS AIRPORT_SERVICE_2, city AS CITY_0, city AS CITY_1, city AS CITY_2, flight, flight_stop, food_service WHERE ((CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'DALLAS'...
### Instruction: list the top three most common drugs that patients are prescribed with during the same month after being diagnosed with hypocalcemia - due to rhabdomyolysis until 2 years ago. ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, 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 = 'hypocalcemia - due to rhabdomyolysis' AND DATETIME...
### Instruction: what're the flights from NEW YORK to LAS VEGAS that arrive on a SUNDAY ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, days, flight WHERE (((((flight.arrival_time < 41 OR flight.time_elapsed >= 60) AND flight.departure_time > flight.arrival_time) AND days.day_name = 'SATURDAY' AND flight.flig...
### Instruction: is patient 10855's temperature c (calc) last measured on the current icu visit less than first measured on the current icu visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10855) AND icustays.outtime IS NULL) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_i...
### Instruction: how much changed in heart rate for patient 4401 second measured on the current intensive care unit visit compared to the value first measured on the current intensive care unit visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 4401) AND icustays.outtime IS NULL) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_it...
### Instruction: list of questions with close votes that need just 1 downvote to be deleted. http://meta.stackexchange.com/questions/78048/enable-automatic-deletion-of-old-unanswered-zero-score-questions-after-a-year/92006#92006 No need to vote to close these as 1 downvote should delete them anytime within the next 7 d...
SELECT q.Id AS "post_link", COUNT(pf.FlagTypeId) FROM Posts AS q INNER JOIN Users AS u ON u.Id = q.OwnerUserId INNER JOIN PostHistory AS ph ON ph.Id = q.Id INNER JOIN PendingFlags AS pf ON pf.PostId = q.Id WHERE q.PostTypeId = 1 AND DATEDIFF(DAY, q.CreationDate, GETDATE()) > 365 AND q.Score = 0 AND q.AnswerCount = 0 AN...
### Instruction: what difference in the weight of patient 2518 last measured on the current hospital visit compared to the value second to last measured on the current hospital visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2518 AND admissions.dischtime IS NULL)) AND chartevents.itemid IN (SELECT d_items.itemid FROM ...
### Instruction: how much was patient 15794's weight changed second measured on the current hospital visit compared to the first value measured on the current hospital visit? ### Response:
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15794 AND admissions.dischtime IS NULL)) AND chartevents.itemid IN (SELECT d_items.itemid FROM...
### Instruction: count the numbers of patients who were diagnosed with acute respiratory distress and did not come back to the hospital within 2 months in 2105. ### Response:
SELECT (SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'acute respiratory distress' AND STRFTIME('%y', diagnosis.diagnosistime) = '2105') AS t1) - (SELECT C...
### Instruction: what are the four most commonly prescribed medications for patients, which were also previously prescribed to patients with 1000 ml flex cont: lactated ringers iv soln during the same month until 2104? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = '1000 ml flex cont: lactated ringers iv soln' AND ST...
### Instruction: what were the three most commonly performed procedures for patients who had received special care bed previously within 2 months, in a year before? ### Response:
SELECT t3.treatmentname FROM (SELECT t2.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'special care bed' AND DATETIME(treatment...
### Instruction: count the number of patients who have been dead after having been diagnosed with abn blood chemistry nec in the same month since 2101. ### Response:
SELECT COUNT(DISTINCT t2.subject_id) FROM (SELECT t1.subject_id, t1.charttime FROM (SELECT admissions.subject_id, diagnoses_icd.charttime 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_di...
### Instruction: what are the five most frequent drugs that were prescribed within 2 months to patients aged 60 or above after they had been diagnosed with anemia, until 2102? ### Response:
SELECT t3.drugname FROM (SELECT t2.drugname, 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 = 'anemia' AND STRFTIME('%y', diagnosis.diagnosistime...