instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
since 2105, what are the top five most frequently ordered laboratory tests for patients within 2 months after they have been diagnosed with cholangiocarcinoma?
### 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 = 'cholangiocarcinoma' 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(t2.labresulttime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month') GROUP BY t2.labname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
what are the five most frequent lab tests patients have taken within the same month after being diagnosed with senile dementia uncomp?
### 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.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'senile dementia uncomp')) AS t1 JOIN (SELECT admissions.subject_id, labevents.itemid, labevents.charttime FROM labevents JOIN admissions ON labevents.hadm_id = admissions.hadm_id) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND DATETIME(t1.charttime, 'start of month') = DATETIME(t2.charttime, 'start of month') GROUP BY t2.itemid) AS t3 WHERE t3.c1 <= 5)
|
### Instruction:
what are the top four most frequent microbiology tests that the patients had within 2 months after they had a hypothermia procedure?
### 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 FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'hypothermia')) AS t1 JOIN (SELECT admissions.subject_id, microbiologyevents.spec_type_desc, microbiologyevents.charttime FROM microbiologyevents JOIN admissions ON microbiologyevents.hadm_id = admissions.hadm_id) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND DATETIME(t2.charttime) BETWEEN DATETIME(t1.charttime) AND DATETIME(t1.charttime, '+2 month') GROUP BY t2.spec_type_desc) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
what are the five most frequently used procedures for patients who were diagnosed with brain tumor - brain tumor, type unknown previously during the same month until 2102?
### 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 = 'brain tumor - brain tumor, type unknown' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2102') AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmentname, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', treatment.treatmenttime) <= '2102') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.treatmenttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.treatmenttime, 'start of month') GROUP BY t2.treatmentname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
how many patients are prescribed oxycodone-acetaminophen 5-325 mg po tabs within 2 months after receiving a calcium channel blocker procedure during this year?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'calcium channel blocker' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'oxycodone-acetaminophen 5-325 mg po tabs' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.treatmenttime) AND DATETIME(t1.treatmenttime, '+2 month')
|
### Instruction:
since 1 year ago, what were the top four most frequent laboratory tests ordered for patients within 2 months after receiving a glucocorticoid administration - oral?
### 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 = 'glucocorticoid administration - oral' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t1 JOIN (SELECT patient.uniquepid, lab.labname, lab.labresulttime FROM lab JOIN patient ON lab.patientunitstayid = patient.patientunitstayid WHERE DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.labresulttime AND DATETIME(t2.labresulttime) BETWEEN DATETIME(t1.treatmenttime) AND DATETIME(t1.treatmenttime, '+2 month') GROUP BY t2.labname) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
what are the three most commonly ordered procedures for patients who had been previously diagnosed with suicidal ideation within the same month until 3 years ago?
### 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 = 'suicidal ideation' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-3 year')) AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmentname, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-3 year')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.treatmenttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.treatmenttime, 'start of month') GROUP BY t2.treatmentname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
i need flight information for flights departing from CLEVELAND going back to MILWAUKEE wednesday after 1700
### Response:
|
SELECT DISTINCT flight_id FROM flight WHERE (((departure_time > 1700 AND 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 = 23 AND DATE_DAYalias0.month_number = 4 AND DATE_DAYalias0.year = 1991))) AND to_airport IN (SELECT AIRPORT_SERVICEalias1.airport_code FROM airport_service AS AIRPORT_SERVICEalias1 WHERE AIRPORT_SERVICEalias1.city_code IN (SELECT CITYalias1.city_code FROM city AS CITYalias1 WHERE CITYalias1.city_name = 'MILWAUKEE'))) AND from_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'CLEVELAND')))
|
### Instruction:
what number of patients were prescribed sodium chloride 0.9% 500 ml lvp within 2 months after receiving a insulin - subcutaneous dose of longer-acting insulin prepara procedure until 2104?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'insulin - subcutaneous dose of longer-acting insulin prepara' AND STRFTIME('%y', treatment.treatmenttime) <= '2104') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'sodium chloride 0.9% 500 ml lvp' AND STRFTIME('%y', medication.drugstarttime) <= '2104') AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.treatmenttime) AND DATETIME(t1.treatmenttime, '+2 month')
|
### Instruction:
what types of aircraft can i get a FIRST class ticket from PHILADELPHIA to DALLAS
### Response:
|
SELECT DISTINCT aircraft.aircraft_code FROM aircraft, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, equipment_sequence, fare, fare_basis, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND fare_basis.class_type = 'FIRST' AND fare.fare_basis_code = fare_basis.fare_basis_code AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND equipment_sequence.aircraft_code = aircraft.aircraft_code AND flight.aircraft_code_sequence = equipment_sequence.aircraft_code_sequence AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
what were the five most frequently ordered microbiology tests for patients who had previously received cardiology consultation within the same month until 2104?
### 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 = 'cardiology consultation' AND STRFTIME('%y', treatment.treatmenttime) <= '2104') AS t1 JOIN (SELECT patient.uniquepid, microlab.culturesite, microlab.culturetakentime FROM microlab JOIN patient ON microlab.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', microlab.culturetakentime) <= '2104') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.culturetakentime AND DATETIME(t1.treatmenttime, 'start of month') = DATETIME(t2.culturetakentime, 'start of month') GROUP BY t2.culturesite) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
in the case of patients who received surgical drains - biliary since 1 year ago, what were the top five most common lab tests that followed during the same hospital encounter?
### Response:
|
SELECT t3.labname FROM (SELECT t2.labname, 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 = 'surgical drains - biliary' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t1 JOIN (SELECT patient.uniquepid, lab.labname, lab.labresulttime, patient.patienthealthsystemstayid FROM lab JOIN patient ON lab.patientunitstayid = patient.patientunitstayid WHERE DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.labresulttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid GROUP BY t2.labname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
how many patients received a blepharorrhaphy after the first serum transfusion nec within 2 months?
### 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 = 'serum transfusion nec')) AS t1 JOIN (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 = 'blepharorrhaphy')) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND DATETIME(t2.charttime) BETWEEN DATETIME(t1.charttime) AND DATETIME(t1.charttime, '+2 month')
|
### Instruction:
Does the Spring-Summer curriculum allow me to take MFG 582 ?
### Response:
|
SELECT COUNT(*) > 0 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 COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id AND NOT COURSEalias0.course_id IN (DERIVED_TABLEalias0.course_id) AND NOT COURSEalias0.course_id IN (SELECT DISTINCT COURSE_PREREQUISITEalias0.course_id FROM course_prerequisite AS COURSE_PREREQUISITEalias0 WHERE NOT COURSE_PREREQUISITEalias0.pre_course_id IN (DERIVED_TABLEalias0.course_id)) AND COURSEalias0.department = 'MFG' AND COURSEalias0.number = 582 AND SEMESTERalias0.semester = 'Spring-Summer' AND SEMESTERalias0.semester_id = COURSE_OFFERINGalias0.semester AND SEMESTERalias0.year = 2016
|
### Instruction:
i would like a flight on CO leaving from BOSTON making a stop in DENVER and arriving in SAN FRANCISCO
### 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 WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'DENVER' AND flight_stop.stop_airport = AIRPORT_SERVICE_2.airport_code AND flight.flight_id = flight_stop.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'CO'
|
### Instruction:
until 2103 what are the top three most frequent diagnoses that patients have received during the same month after receiving a bronchodilator - metered dose?
### Response:
|
SELECT t3.diagnosisname FROM (SELECT t2.diagnosisname, 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 = 'bronchodilator - metered dose' AND STRFTIME('%y', treatment.treatmenttime) <= '2103') AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosisname, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', diagnosis.diagnosistime) <= '2103') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.diagnosistime AND DATETIME(t1.treatmenttime, 'start of month') = DATETIME(t2.diagnosistime, 'start of month') GROUP BY t2.diagnosisname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
i would like a flight on AA from BALTIMORE to SAN FRANCISCO with a stop in DENVER
### 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 WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'DENVER' AND flight_stop.stop_airport = AIRPORT_SERVICE_2.airport_code AND flight.flight_id = flight_stop.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
during the last year, how many patients were diagnosed with asthma / bronchospasm within 2 months after they were diagnosed with hyperglycemia - stress related?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'asthma / bronchospasm' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hyperglycemia - stress related' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t2 WHERE t1.diagnosistime < t2.diagnosistime AND DATETIME(t2.diagnosistime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')
|
### Instruction:
what were the top five frequently prescribed drugs that patients were prescribed during the same hospital visit after having received a ventilator weaning procedure since 2102?
### Response:
|
SELECT t3.drugname FROM (SELECT t2.drugname, 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 = 'ventilator weaning' AND STRFTIME('%y', treatment.treatmenttime) >= '2102') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime, patient.patienthealthsystemstayid FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', medication.drugstarttime) >= '2102') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.drugstarttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
what are the three commonest prescribed drugs for patients who previously were prescribed calcium chloride within 2 months 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 = 'calcium chloride' AND STRFTIME('%y', medication.drugstarttime) <= '2104') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', medication.drugstarttime) <= '2104') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.drugstarttime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.drugstarttime) AND DATETIME(t1.drugstarttime, '+2 month') GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
what are the top three most common medications that followed within the same month for those who were given electrolyte administration - potassium until 1 year ago?
### 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 = 'electrolyte administration - potassium' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.drugstarttime AND DATETIME(t1.treatmenttime, 'start of month') = DATETIME(t2.drugstarttime, 'start of month') GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
In 2015 , can I take PHYSICS 452 in the Spring ?
### Response:
|
SELECT COUNT(*) > 0 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 COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id AND NOT COURSEalias0.course_id IN (DERIVED_TABLEalias0.course_id) AND NOT COURSEalias0.course_id IN (SELECT DISTINCT COURSE_PREREQUISITEalias0.course_id FROM course_prerequisite AS COURSE_PREREQUISITEalias0 WHERE NOT COURSE_PREREQUISITEalias0.pre_course_id IN (DERIVED_TABLEalias0.course_id)) AND COURSEalias0.department = 'PHYSICS' AND COURSEalias0.number = 452 AND SEMESTERalias0.semester = 'Spring' AND SEMESTERalias0.semester_id = COURSE_OFFERINGalias0.semester AND SEMESTERalias0.year = 2015
|
### Instruction:
what are the top four most frequent specimen tests ordered for patients during the same month after they have been diagnosed with excessive cold 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_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'excessive cold nec')) AS t1 JOIN (SELECT admissions.subject_id, microbiologyevents.spec_type_desc, microbiologyevents.charttime FROM microbiologyevents JOIN admissions ON microbiologyevents.hadm_id = admissions.hadm_id) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND DATETIME(t1.charttime, 'start of month') = DATETIME(t2.charttime, 'start of month') GROUP BY t2.spec_type_desc) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
how much is patient 008-19005's different systemicsystolic second measured on the last intensive care unit visit compared to the first value measured on the last intensive care unit visit?
### Response:
|
SELECT (SELECT vitalperiodic.systemicsystolic FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '008-19005') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.systemicsystolic IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1 OFFSET 1) - (SELECT vitalperiodic.systemicsystolic FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '008-19005') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.systemicsystolic IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1)
|
### Instruction:
what are the five most commonly prescribed drugs at the same time since 2 years ago among patients who were prescribed zosyn 3.375 gram in ns 100 ml ivpb?
### 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 = 'zosyn 3.375 gram in ns 100 ml ivpb' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-2 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-2 year')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE DATETIME(t1.drugstarttime) = DATETIME(t2.drugstarttime) GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
what were the three most commonly ordered procedures for patients who previously received electrolyte administration - intravenous within 2 months since 2105?
### 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 = 'electrolyte administration - intravenous' AND STRFTIME('%y', treatment.treatmenttime) >= '2105') AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmentname, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', treatment.treatmenttime) >= '2105') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.treatmenttime AND DATETIME(t2.treatmenttime) BETWEEN DATETIME(t1.treatmenttime) AND DATETIME(t1.treatmenttime, '+2 month') GROUP BY t2.treatmentname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
find a transcontinental flight on AA from BOSTON to SAN FRANCISCO that makes a stopover in DENVER
### 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 WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'DENVER' AND flight_stop.stop_airport = AIRPORT_SERVICE_2.airport_code AND flight.flight_id = flight_stop.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
how many patients was diagnosed with hypopotassemia during the same hospital encounter after being diagnosed with left bb block nec?
### 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 = 'hypopotassemia')) AS t1 JOIN (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 = 'left bb block nec')) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND t1.hadm_id = t2.hadm_id
|
### Instruction:
Is MEDCHEM 533 available for me in the Spring-Summer ?
### Response:
|
SELECT COUNT(*) > 0 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 COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id AND NOT COURSEalias0.course_id IN (DERIVED_TABLEalias0.course_id) AND NOT COURSEalias0.course_id IN (SELECT DISTINCT COURSE_PREREQUISITEalias0.course_id FROM course_prerequisite AS COURSE_PREREQUISITEalias0 WHERE NOT COURSE_PREREQUISITEalias0.pre_course_id IN (DERIVED_TABLEalias0.course_id)) AND COURSEalias0.department = 'MEDCHEM' AND COURSEalias0.number = 533 AND SEMESTERalias0.semester = 'Spring-Summer' AND SEMESTERalias0.semester_id = COURSE_OFFERINGalias0.semester AND SEMESTERalias0.year = 2016
|
### Instruction:
list WEDNESDAY night flights from OAKLAND to SALT LAKE CITY
### 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.departure_time <= 2359 AND flight.departure_time >= 1800) AND days.day_name = 'WEDNESDAY' AND flight.flight_days = days.days_code) OR ((flight.departure_time <= departure_time2 AND flight.departure_time >= departure_time3) AND days.day_name = 'day_name1' AND flight.flight_days = days.days_code)) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SALT LAKE CITY' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'OAKLAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
what were the five most frequently ordered procedures for patients who had previously been given angiogram - with stenting during the same hospital encounter in 2105?
### Response:
|
SELECT t3.treatmentname FROM (SELECT t2.treatmentname, 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 = 'angiogram - with stenting' AND STRFTIME('%y', treatment.treatmenttime) = '2105') AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmentname, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', treatment.treatmenttime) = '2105') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.treatmenttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid GROUP BY t2.treatmentname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
what are the three most commonly prescribed medications for patients, which were also previously prescribed to patients with flecainide acetate within 2 months in 2105?
### Response:
|
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'flecainide acetate' AND STRFTIME('%y', prescriptions.startdate) = '2105') AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE STRFTIME('%y', prescriptions.startdate) = '2105') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.startdate < t2.startdate AND DATETIME(t2.startdate) BETWEEN DATETIME(t1.startdate) AND DATETIME(t1.startdate, '+2 month') GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
what are the flights from PITTSBURGH to DENVER and back
### 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 = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) OR (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PITTSBURGH' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code)
|
### Instruction:
since 2105, what are the top four most frequent lab tests ordered for patients during the same hospital visit after having received esophagogastroduodenoscopy - with biopsy?
### Response:
|
SELECT t3.labname FROM (SELECT t2.labname, 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 = 'esophagogastroduodenoscopy - with biopsy' AND STRFTIME('%y', treatment.treatmenttime) >= '2105') AS t1 JOIN (SELECT patient.uniquepid, lab.labname, lab.labresulttime, patient.patienthealthsystemstayid FROM lab JOIN patient ON lab.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', lab.labresulttime) >= '2105') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.labresulttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid GROUP BY t2.labname) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
Weighted Score of more 'successful' users. Tries to gauge success by weighting number of answers by acceptance percentage. This is done as a way to weed out people who post very infrequently, but are accepted often (counter productive perhaps, but too cautious for my likes).
### Response:
|
SELECT u.Id AS "user_link", COUNT(*) AS NumAnswers, SUM(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END) AS NumAccepted, (SUM(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END) * 100.0 / (COUNT(*))) AS AcceptedPercent, SUM(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END) * (SUM(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END) * 100.0 / (COUNT(*))) / 100 AS WeightedScore FROM Posts AS a INNER JOIN Users AS u ON u.Id = a.OwnerUserId INNER JOIN Posts AS q ON a.ParentId = q.Id WHERE (q.OwnerUserId != u.Id OR q.OwnerUserId IS NULL) AND u.Id = 918414 GROUP BY u.Id ORDER BY WeightedScore DESC, AcceptedPercent DESC, NumAnswers DESC LIMIT 1000
|
### Instruction:
count the number of patients who are dead after having been diagnosed with acute coronary syndrome - acute myocardial infarction (no st elevation) within the same hospital visit since 2102.
### Response:
|
SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT t1.uniquepid, t1.diagnosistime, t1.patienthealthsystemstayid FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'acute coronary syndrome - acute myocardial infarction (no st elevation)') AS t1 GROUP BY t1.uniquepid HAVING MIN(t1.diagnosistime) = t1.diagnosistime AND STRFTIME('%y', t1.diagnosistime) >= '2102') AS t2 JOIN (SELECT patient.uniquepid, patient.patienthealthsystemstayid, patient.hospitaldischargetime FROM patient WHERE patient.hospitaldischargestatus = 'expired') AS t3 ON t2.uniquepid = t3.uniquepid WHERE t2.patienthealthsystemstayid = t3.patienthealthsystemstayid
|
### Instruction:
show me all flights direct only from BOSTON to SAN FRANCISCO or OAKLAND that arrive before 1000 local time
### 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 WHERE ((((flight.to_airport = AIRPORT_SERVICE_1.airport_code AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO') OR (flight.to_airport = AIRPORT_SERVICE_2.airport_code AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'OAKLAND')) AND flight.arrival_time < 1000) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.connections = 0
|
### Instruction:
find me a flight from BOSTON to SAN FRANCISCO with layover in DENVER on UA
### 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 WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'DENVER' AND flight_stop.stop_airport = AIRPORT_SERVICE_2.airport_code AND flight.flight_id = flight_stop.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'UA'
|
### Instruction:
i need a flight from OAKLAND to SALT LAKE CITY on wednesday departing after 1800
### Response:
|
SELECT DISTINCT flight_id FROM flight WHERE (((departure_time > 1800 AND 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 = 23 AND DATE_DAYalias0.month_number = 4 AND DATE_DAYalias0.year = 1991))) AND to_airport IN (SELECT AIRPORT_SERVICEalias1.airport_code FROM airport_service AS AIRPORT_SERVICEalias1 WHERE AIRPORT_SERVICEalias1.city_code IN (SELECT CITYalias1.city_code FROM city AS CITYalias1 WHERE CITYalias1.city_name = 'SALT LAKE CITY'))) AND from_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'OAKLAND')))
|
### Instruction:
sure i'd like to determine what aircraft are use on 7 7 leaving from BOSTON and arriving in ATLANTA on 7 7
### Response:
|
SELECT DISTINCT aircraft.aircraft_code FROM aircraft, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, equipment_sequence, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND date_day.day_number = 7 AND date_day.month_number = 7 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND equipment_sequence.aircraft_code = aircraft.aircraft_code AND flight.aircraft_code_sequence = equipment_sequence.aircraft_code_sequence AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Seek and Destroy: Spam spam URLs spam baked beans and spam. A query to help look for spam--finds short posts containing URLs, and shows the ratio of such posts to total posts, per-user. Lots of these are at least borderline spam, and most of the rest are probably poor quality posts anyway. Whee!
### Response:
|
SELECT u.Id AS "user_link", u.Reputation AS "user_rep", p.n AS "total_posts", bad.n AS "dubious_posts", CAST(bad.n AS FLOAT) / CAST(p.n AS FLOAT) AS "ratio" FROM Users AS u INNER JOIN (SELECT p.OwnerUserId AS uid, COUNT(p.Id) AS n FROM Posts AS p GROUP BY p.OwnerUserId) AS p ON p.uid = u.Id INNER JOIN (SELECT p.OwnerUserId AS uid, COUNT(p.Id) AS n FROM Posts AS p WHERE LENGTH(p.Body) < 500 AND p.Body LIKE '%http://%' GROUP BY p.OwnerUserId) AS bad ON bad.uid = u.Id WHERE u.Reputation < 10 AND p.n > 2 AND CAST(bad.n AS FLOAT) / CAST(p.n AS FLOAT) > 0.5 ORDER BY 'ratio' DESC
|
### Instruction:
list nonstop flights from SFO to OAK that depart in the afternoon
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport AS AIRPORT_0, airport AS AIRPORT_1, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE ((((AIRPORT_0.airport_code = 'SFO' AND AIRPORT_1.airport_code = 'OAK' AND flight.from_airport = AIRPORT_0.airport_code AND flight.to_airport = AIRPORT_1.airport_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'OAKLAND' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 1200 AND 1800) AND flight.stops = 0
|
### Instruction:
Questions possibly with Chem.SE buzzwords in the title. Exclude any particular category of buzzword by setting its 'ignore' threshold to a large negative number.
### Response:
|
SELECT p.Id AS "post_link", p.Score AS "Score", p.Tags AS "Tags" FROM Posts AS p WHERE p.PostTypeId = 1 AND (STR_POSITION(UPPER(p.Title), 'DOUBT') > 0 OR STR_POSITION(UPPER(p.Title), 'QUESTION') > 0 OR STR_POSITION(UPPER(p.Title), 'HELP') > 0 OR STR_POSITION(UPPER(p.Title), 'PROBLEM') > 0 OR (STR_POSITION(UPPER(p.Title), 'EXPERIMENT') > 0 AND p.Score <= @ExptScore) OR STR_POSITION(UPPER(p.Title), 'EXERCISE') > 0 OR (STR_POSITION(UPPER(p.Title), ' CHEMISTR') > 0 AND p.Score <= @ChemScore) OR (STR_POSITION(UPPER(p.Title), ' CHEMIC') > 0 AND p.Score <= @ChemScore) OR (STR_POSITION(UPPER(p.Title), 'CHEM') = 1 AND p.Score <= @ChemScore)) ORDER BY p.Score
|
### Instruction:
can you find me another flight from CINCINNATI to NEW YORK on saturday before 1800
### Response:
|
SELECT DISTINCT flight_id FROM flight WHERE (((departure_time < 1800 AND 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 to_airport IN (SELECT AIRPORT_SERVICEalias1.airport_code FROM airport_service AS AIRPORT_SERVICEalias1 WHERE AIRPORT_SERVICEalias1.city_code IN (SELECT CITYalias1.city_code FROM city AS CITYalias1 WHERE CITYalias1.city_name = 'NEW YORK'))) AND from_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'CINCINNATI')))
|
### Instruction:
is there a direct flight from DENVER to PITTSBURGH in the morning of 8 31 that is nonstop
### 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 ((((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND date_day.day_number = 31 AND date_day.month_number = 8 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 0 AND 1200) AND flight.stops = 0) AND flight.connections = 0
|
### Instruction:
Am I allowed to take AEROSP 714 and AEROSP 566 in the same semester ?
### Response:
|
SELECT COUNT(*) > 0 FROM course AS COURSE_0, course AS COURSE_1, course_offering AS COURSE_OFFERING_0, course_offering AS COURSE_OFFERING_1, course_prerequisite WHERE COURSE_OFFERING_1.semester = COURSE_OFFERING_0.semester AND COURSE_0.course_id = COURSE_OFFERING_0.course_id AND COURSE_0.department = 'AEROSP' AND COURSE_0.number = 714 AND COURSE_1.course_id = COURSE_OFFERING_1.course_id AND COURSE_1.department = 'AEROSP' AND COURSE_1.number = 566 AND (NOT ((COURSE_1.course_id = course_prerequisite.course_id AND COURSE_0.course_id = course_prerequisite.pre_course_id) OR (COURSE_1.course_id = course_prerequisite.pre_course_id AND COURSE_0.course_id = course_prerequisite.course_id)))
|
### Instruction:
when had patient 017-16041 first been prescribed for infuvite iv inj 10ml and potassium chloride at the same time in 12/2105?
### Response:
|
SELECT t1.drugstarttime FROM (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'infuvite iv inj 10ml' AND patient.uniquepid = '017-16041' AND STRFTIME('%y-%m', medication.drugstarttime) = '2105-12') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'potassium chloride' AND patient.uniquepid = '017-16041' AND STRFTIME('%y-%m', medication.drugstarttime) = '2105-12') AS t2 ON t1.uniquepid = t2.uniquepid WHERE DATETIME(t1.drugstarttime) = DATETIME(t2.drugstarttime) ORDER BY t1.drugstarttime LIMIT 1
|
### Instruction:
i need a morning flight from BURBANK to MILWAUKEE on next monday
### 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 = 21 AND DATE_DAYalias0.month_number = 2 AND DATE_DAYalias0.year = 1991)) AND to_airport IN (SELECT AIRPORT_SERVICEalias1.airport_code FROM airport_service AS AIRPORT_SERVICEalias1 WHERE AIRPORT_SERVICEalias1.city_code IN (SELECT CITYalias1.city_code FROM city AS CITYalias1 WHERE CITYalias1.city_name = 'MILWAUKEE'))) AND from_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'BURBANK'))) AND departure_time BETWEEN 0 AND 1200)
|
### Instruction:
how many patients were diagnosed with post neurointerventional procedure - embolization within the same hospital visit in the last year after the first diagnosis with hypervolemia?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'post neurointerventional procedure - embolization' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hypervolemia' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t2 WHERE t1.diagnosistime < t2.diagnosistime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
### Instruction:
what are the three most commonly used procedures for patients that have previously received insulin - continuous infusion during the same month, until 4 years ago?
### 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 = 'insulin - continuous infusion' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-4 year')) AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmentname, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-4 year')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.treatmenttime AND DATETIME(t1.treatmenttime, 'start of month') = DATETIME(t2.treatmenttime, 'start of month') GROUP BY t2.treatmentname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
Is FILMVID 503 available for me to take over the Fall ?
### Response:
|
SELECT COUNT(*) > 0 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 COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id AND NOT COURSEalias0.course_id IN (DERIVED_TABLEalias0.course_id) AND NOT COURSEalias0.course_id IN (SELECT DISTINCT COURSE_PREREQUISITEalias0.course_id FROM course_prerequisite AS COURSE_PREREQUISITEalias0 WHERE NOT COURSE_PREREQUISITEalias0.pre_course_id IN (DERIVED_TABLEalias0.course_id)) AND COURSEalias0.department = 'FILMVID' AND COURSEalias0.number = 503 AND SEMESTERalias0.semester = 'Fall' AND SEMESTERalias0.semester_id = COURSE_OFFERINGalias0.semester AND SEMESTERalias0.year = 2016
|
### Instruction:
show me all flights from PHILADELPHIA to BOSTON on monday which serve a meal and arrive before 1200
### 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, food_service WHERE (((flight.arrival_time < 1200 AND food_service.meal_code = flight.meal_code) AND date_day.day_number = 21 AND date_day.month_number = 2 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
This Winter , will STRATEGY 398 be available for me ?
### Response:
|
SELECT COUNT(*) > 0 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 COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id AND NOT COURSEalias0.course_id IN (DERIVED_TABLEalias0.course_id) AND NOT COURSEalias0.course_id IN (SELECT DISTINCT COURSE_PREREQUISITEalias0.course_id FROM course_prerequisite AS COURSE_PREREQUISITEalias0 WHERE NOT COURSE_PREREQUISITEalias0.pre_course_id IN (DERIVED_TABLEalias0.course_id)) AND COURSEalias0.department = 'STRATEGY' AND COURSEalias0.number = 398 AND SEMESTERalias0.semester = 'Winter' AND SEMESTERalias0.semester_id = COURSE_OFFERINGalias0.semester AND SEMESTERalias0.year = 2016
|
### Instruction:
what are the flight numbers of the flights which go from SAN FRANCISCO to WASHINGTON via INDIANAPOLIS
### 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 WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'WASHINGTON' AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'INDIANAPOLIS' AND flight_stop.stop_airport = AIRPORT_SERVICE_2.airport_code AND flight.flight_id = flight_stop.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
how many patients until 2101 were prescribed heparin within the same month after diagnosis of hyperparathyroidism nos?
### 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 = 'hyperparathyroidism nos') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2101') AS t1 JOIN (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'heparin' AND STRFTIME('%y', prescriptions.startdate) <= '2101') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.startdate AND DATETIME(t1.charttime, 'start of month') = DATETIME(t2.startdate, 'start of month')
|
### Instruction:
what was the top five most frequent drugs prescribed to patients during the same hospital visit after they had been prescribed chlorothiazide sodium since 5 years ago?
### Response:
|
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, prescriptions.startdate, admissions.hadm_id FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'chlorothiazide sodium' AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-5 year')) 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 DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-5 year')) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.startdate < t2.startdate AND t1.hadm_id = t2.hadm_id GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
wednesday morning flights between BALTIMORE and NEWARK NEW JERSEY
### 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, state WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NEWARK' AND date_day.day_number = 23 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code AND state.state_code = CITY_1.state_code AND state.state_name = 'NEW JERSEY') AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
for patients who were prescribed with ondansetron hcl (pf) 4 mg/2 ml inj soln, what are the four most commonly prescribed drugs at the same time, 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 = 'ondansetron hcl (pf) 4 mg/2 ml inj soln' AND STRFTIME('%y', medication.drugstarttime) <= '2104') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', medication.drugstarttime) <= '2104') AS t2 ON t1.uniquepid = t2.uniquepid WHERE DATETIME(t1.drugstarttime) = DATETIME(t2.drugstarttime) GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
in 2104, what were the top four most common laboratory tests that were ordered to patients in the same hospital encounter after being diagnosed with intracranial injury?
### Response:
|
SELECT t3.labname FROM (SELECT t2.labname, 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 = 'intracranial injury' AND STRFTIME('%y', diagnosis.diagnosistime) = '2104') AS t1 JOIN (SELECT patient.uniquepid, lab.labname, lab.labresulttime, patient.patienthealthsystemstayid FROM lab JOIN patient ON lab.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', lab.labresulttime) = '2104') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.labresulttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid GROUP BY t2.labname) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
what was the last time patient 002-55218 was prescribed carvedilol 25 mg po tabs and morphine until 50 months ago, at the same time?
### Response:
|
SELECT t1.drugstarttime FROM (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'carvedilol 25 mg po tabs' AND patient.uniquepid = '002-55218' AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-50 month')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'morphine' AND patient.uniquepid = '002-55218' AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-50 month')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE DATETIME(t1.drugstarttime) = DATETIME(t2.drugstarttime) ORDER BY t1.drugstarttime DESC LIMIT 1
|
### Instruction:
what are the top four most frequent drugs that patients were prescribed with within 2 months after receiving opn/oth rep aortic valve?
### 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 WHERE d_icd_procedures.short_title = 'opn/oth rep aortic valve')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.startdate AND DATETIME(t2.startdate) BETWEEN DATETIME(t1.charttime) AND DATETIME(t1.charttime, '+2 month') GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
Avg time in hours between Q posted and accepted A posted.
### Response:
|
SELECT AVG(CAST((JULIANDAY(CreationDate) - JULIANDAY(Q.CreationDate)) * 24.0 AS INT)) AS AllTags, AVG(CASE WHEN Q.Tags LIKE '%sql-server%' THEN CAST((JULIANDAY(CreationDate) - JULIANDAY(Q.CreationDate)) * 24.0 AS INT) END) AS SQLServer, AVG(CASE WHEN Q.Tags LIKE '%oracle%' THEN CAST((JULIANDAY(CreationDate) - JULIANDAY(Q.CreationDate)) * 24.0 AS INT) END) AS Oracle, AVG(CASE WHEN Q.Tags LIKE '%mysql%' THEN CAST((JULIANDAY(CreationDate) - JULIANDAY(Q.CreationDate)) * 24.0 AS INT) END) AS MySQL, AVG(CASE WHEN Q.Tags LIKE '%postgresql%' THEN CAST((JULIANDAY(CreationDate) - JULIANDAY(Q.CreationDate)) * 24.0 AS INT) END) AS PostgreSQL FROM Posts AS Q INNER JOIN Posts AS A ON A.Id = Q.AcceptedAnswerId WHERE Q.CreationDate >= @FromDate AND Q.CreationDate < @ToDate
|
### Instruction:
show me the flights from BOSTON to SAN FRANCISCO stopping in DALLAS on AA
### 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 WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'DALLAS' AND flight_stop.stop_airport = AIRPORT_SERVICE_2.airport_code AND flight.flight_id = flight_stop.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
what were the three most commonly prescribed medications during a year before for patients who were also prescribed with methylprednisolone sodium succ at the same time?
### Response:
|
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'methylprednisolone sodium succ' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t2 ON t1.subject_id = t2.subject_id WHERE DATETIME(t1.startdate) = DATETIME(t2.startdate) GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
show me the flights from DENVER to BALTIMORE or WASHINGTON that arrive before or around noon
### 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 WHERE (((flight.to_airport = AIRPORT_SERVICE_1.airport_code AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE') OR (flight.to_airport = AIRPORT_SERVICE_2.airport_code AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'WASHINGTON' AND CITY_2.state_code = 'DC')) AND flight.arrival_time < 1230) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Can THTREMUS 332 and THTREMUS 274 be taken together ?
### Response:
|
SELECT COUNT(*) > 0 FROM course AS COURSE_0, course AS COURSE_1, course_offering AS COURSE_OFFERING_0, course_offering AS COURSE_OFFERING_1, course_prerequisite WHERE COURSE_OFFERING_1.semester = COURSE_OFFERING_0.semester AND COURSE_0.course_id = COURSE_OFFERING_0.course_id AND COURSE_0.department = 'THTREMUS' AND COURSE_0.number = 332 AND COURSE_1.course_id = COURSE_OFFERING_1.course_id AND COURSE_1.department = 'THTREMUS' AND COURSE_1.number = 274 AND (NOT ((COURSE_1.course_id = course_prerequisite.course_id AND COURSE_0.course_id = course_prerequisite.pre_course_id) OR (COURSE_1.course_id = course_prerequisite.pre_course_id AND COURSE_0.course_id = course_prerequisite.course_id)))
|
### Instruction:
what were the three most common microbiological tests that followed in the same hospital visit for patients who took inject into thorax cavit?
### 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, 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_title = 'inject into thorax cavit')) AS t1 JOIN (SELECT admissions.subject_id, microbiologyevents.spec_type_desc, microbiologyevents.charttime, admissions.hadm_id FROM microbiologyevents JOIN admissions ON microbiologyevents.hadm_id = admissions.hadm_id) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND t1.hadm_id = t2.hadm_id GROUP BY t2.spec_type_desc) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
what is the drug that was prescribed for patient 030-64961 during the same hospital encounter after being diagnosed with unable to protect airway?
### Response:
|
SELECT t2.drugname FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-64961') AND diagnosis.diagnosisname = 'unable to protect airway') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime, patient.patienthealthsystemstayid FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-64961')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.drugstarttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
### Instruction:
how many patients underwent closed bronchial biopsy during the same hospital encounter after having received closed bronchial biopsy,?
### 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_title = 'closed bronchial biopsy')) AS t1 JOIN (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_title = 'closed bronchial biopsy')) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND t1.hadm_id = t2.hadm_id
|
### Instruction:
Which questions have no popular tags?. The proliferation of tags can mean that many questions have no popular tags. Such questions are more difficult to find, and do not contribute to enabling the 'Generalist' badge for smaller sites.
Here, choose a threshold (i.e., 40, for top 40 tags), and this query will return all questions that have no tags that popular. It will also provide the name of the question's most popular tag.
Related: Query 342344 (Which open or duplicate questions have no popular tags?)
### Response:
|
WITH My_Table AS (SELECT t.Id AS Tag_ID, t.TagName AS Tag_Name, t.Count AS Count, p.Id AS Post_ID, p.Title AS Post_Title, p.PostTypeId AS Type, p.OwnerUserId AS Owner, MAX(t.Count) OVER (PARTITION BY p.Id) AS Max_Count FROM Tags AS t INNER JOIN PostTags AS pt ON t.Id = pt.TagId INNER JOIN Posts AS p ON pt.PostId = p.Id) SELECT Tag_ID, Tag_Name, 'site://questions/' + CAST(Post_ID AS TEXT) + '|' + Post_Title AS Post, Max_Count FROM My_Table WHERE Type = 1 AND Max_Count = Count AND Max_Count < @Threshold ORDER BY Max_Count
|
### Instruction:
until 2 years ago, what was the top four most frequent laboratory tests ordered for patients during the same month after the diagnosis of s/p liver transplant?
### 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 = 's/p liver transplant' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-2 year')) AS t1 JOIN (SELECT patient.uniquepid, lab.labname, lab.labresulttime FROM lab JOIN patient ON lab.patientunitstayid = patient.patientunitstayid WHERE DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-2 year')) 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 <= 4
|
### Instruction:
Posts with anonymous feedback and vote score juxtaposed (Anon UV DESC).
### Response:
|
SELECT * FROM (SELECT p.Id AS "post_link", p.Score, SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, SUM(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes FROM Posts AS p, Votes AS v WHERE p.PostTypeId IN (1, 2) AND p.Id = v.PostId AND p.CreationDate >= '2015-01-01' GROUP BY p.Id, p.Score) AS VoteTally INNER JOIN (SELECT p.Id AS "post_link", p.Score, SUM(CASE WHEN f.VoteTypeId = 2 THEN 1 ELSE 0 END) AS AnonUpvotes, SUM(CASE WHEN f.VoteTypeId = 3 THEN 1 ELSE 0 END) AS AnonDownvotes FROM Posts AS p, PostFeedback AS f WHERE p.PostTypeId IN (1, 2) AND p.Id = f.PostId AND p.CreationDate >= '2015-01-01' GROUP BY p.Id, p.Score) AS AnonTally ON AnonTally."post_link" = VoteTally."post_link"
|
### Instruction:
what are the top five most prescribed drugs for patients who were prescribed cefazolin 2 gm in ns 100 ml ivpb (repackage) at the same time since 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 = 'cefazolin 2 gm in ns 100 ml ivpb (repackage)' AND STRFTIME('%y', medication.drugstarttime) >= '2104') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', medication.drugstarttime) >= '2104') AS t2 ON t1.uniquepid = t2.uniquepid WHERE DATETIME(t1.drugstarttime) = DATETIME(t2.drugstarttime) GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
i would like to leave thursday morning from INDIANAPOLIS to TORONTO
### 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 = 24 AND DATE_DAYalias0.month_number = 5 AND DATE_DAYalias0.year = 1991)) AND to_airport IN (SELECT AIRPORT_SERVICEalias1.airport_code FROM airport_service AS AIRPORT_SERVICEalias1 WHERE AIRPORT_SERVICEalias1.city_code IN (SELECT CITYalias1.city_code FROM city AS CITYalias1 WHERE CITYalias1.city_name = 'TORONTO'))) AND from_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'INDIANAPOLIS'))) AND departure_time BETWEEN 0 AND 1200)
|
### Instruction:
how much patient 030-53416's systemicdiastolic has changed last measured on the first icu visit compared to the first value measured on the first icu visit?
### Response:
|
SELECT (SELECT vitalperiodic.systemicdiastolic FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-53416') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND NOT vitalperiodic.systemicdiastolic IS NULL ORDER BY vitalperiodic.observationtime DESC LIMIT 1) - (SELECT vitalperiodic.systemicdiastolic FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-53416') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND NOT vitalperiodic.systemicdiastolic IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1)
|
### Instruction:
what were the three most frequently provided tests for patients who had previously been diagnosed with acute bronchiolitis in the same hospital visit, until 2102?
### Response:
|
SELECT t3.labname FROM (SELECT t2.labname, 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 = 'acute bronchiolitis' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2102') AS t1 JOIN (SELECT patient.uniquepid, lab.labname, lab.labresulttime, patient.patienthealthsystemstayid FROM lab JOIN patient ON lab.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', lab.labresulttime) <= '2102') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.labresulttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid GROUP BY t2.labname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
tell me the number of patients who were prescribed 250 ml plas cont: fat emulsion 20 % iv emul after a hypotonic fluid administration - d5w procedure since 3 years ago during the same hospital encounter.
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'hypotonic fluid administration - d5w' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-3 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime, patient.patienthealthsystemstayid FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = '250 ml plas cont: fat emulsion 20 % iv emul' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-3 year')) AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
### Instruction:
among patients that were prescribed with sterile water for irrigation since 5 years ago, what are the top five most common drugs that followed afterwards 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, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'sterile water for irrigation' AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-5 year')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-5 year')) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.startdate < t2.startdate AND DATETIME(t1.startdate, 'start of month') = DATETIME(t2.startdate, 'start of month') GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
how many patients were prescribed the drug sodium chloride 0.9 % iv soln bolus within 2 months after being diagnosed with esrd (end stage renal disease), since 1 year ago?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'esrd (end stage renal disease)' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'sodium chloride 0.9 % iv soln bolus' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')
|
### Instruction:
how many patients in this year were prescribed promethazine hcl 25 mg/ml ij soln in the same hospital visit after having undergone bronchodilator?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'bronchodilator' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime, patient.patienthealthsystemstayid FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'promethazine hcl 25 mg/ml ij soln' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
### Instruction:
in 2105 how many patients were prescribed with sarna lotion within the same month after they had undergone interruption vena cava?
### 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 = 'interruption vena cava') AND STRFTIME('%y', procedures_icd.charttime) = '2105') AS t1 JOIN (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'sarna lotion' AND STRFTIME('%y', prescriptions.startdate) = '2105') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.startdate AND DATETIME(t1.charttime, 'start of month') = DATETIME(t2.startdate, 'start of month')
|
### Instruction:
what is the three most frequently prescribed drugs for patients that have been prescribed with azithromycin 500 mg in ns 250 ml iv at the same time in 2102?
### 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 = 'azithromycin 500 mg in ns 250 ml iv' AND STRFTIME('%y', medication.drugstarttime) = '2102') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', medication.drugstarttime) = '2102') AS t2 ON t1.uniquepid = t2.uniquepid WHERE DATETIME(t1.drugstarttime) = DATETIME(t2.drugstarttime) GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
how many patients were diagnosed with anxiety and they didn't come back to the hospital during the same month 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 = 'anxiety' AND STRFTIME('%y', diagnosis.diagnosistime) = '2105') AS t1) - (SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'anxiety' AND STRFTIME('%y', diagnosis.diagnosistime) = '2105') AS t2 JOIN patient ON t2.uniquepid = patient.uniquepid WHERE t2.diagnosistime < patient.hospitaladmittime AND STRFTIME('%y', patient.hospitaladmittime) = '2105' AND DATETIME(t2.diagnosistime, 'start of month') = DATETIME(patient.hospitaladmittime, 'start of month'))
|
### Instruction:
what kind of aircraft do you have flying from BOSTON to SAN FRANCISCO on 8 27
### Response:
|
SELECT DISTINCT aircraft.aircraft_code FROM aircraft, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, equipment_sequence, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND date_day.day_number = 27 AND date_day.month_number = 8 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND equipment_sequence.aircraft_code = aircraft.aircraft_code AND flight.aircraft_code_sequence = equipment_sequence.aircraft_code_sequence AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Questions counted by time to first answer (w/o 24 hr restriction, log/log axis).
### Response:
|
SELECT LOG(10, CAST((JULIANDAY(CreationDate) - JULIANDAY(q.CreationDate)) * 1440.0 AS INT)) AS "Log Time (m)", LOG(10, COUNT(*)) FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id LEFT OUTER JOIN Posts AS a2 ON a.ParentId = a2.ParentId AND a.CreationDate > a2.CreationDate WHERE a2.Id IS NULL AND a.CreationDate >= q.CreationDate AND CAST((JULIANDAY(CreationDate) - JULIANDAY(q.CreationDate)) * 24.0 AS INT) > 24 AND CAST((JULIANDAY(CreationDate) - JULIANDAY(q.CreationDate)) * 1440.0 AS INT) > 0 GROUP BY CAST((JULIANDAY(CreationDate) - JULIANDAY(q.CreationDate)) * 1440.0 AS INT) ORDER BY CAST((JULIANDAY(CreationDate) - JULIANDAY(q.CreationDate)) * 1440.0 AS INT)
|
### Instruction:
any 2 of the following: waist circumference > 40 inches in male , > 35 inches in female ; triglycerides > 150 mg / dl; high _ density lipoprotein cholesterol ( hdl _ c ) < 40 mg / dl in male , < 50 mg / dl in female ; systolic blood pressure > 130 mm hg or diastolic blood pressure > 85 mm hg.
### Response:
|
SELECT * FROM table_dev_49 WHERE (CASE WHEN (waist_circumference > 40 AND gender = 'male') OR (waist_circumference > 35 AND gender = 'female') THEN 1 ELSE 0 END + CASE WHEN triglyceride_tg > 150 THEN 1 ELSE 0 END + CASE WHEN (high_density_lipoprotein_cholesterol_hdl_c < 40 AND gender = 'male') OR (high_density_lipoprotein_cholesterol_hdl_c < 50 AND gender = 'female') THEN 1 ELSE 0 END + CASE WHEN systolic_blood_pressure_sbp > 130 OR diastolic_blood_pressure_dbp > 85 THEN 1 ELSE 0 END) >= 2
|
### Instruction:
among patients who have been diagnosed with preterm nec 2500+g tell me the two year survival rate.
### Response:
|
SELECT SUM(CASE WHEN patients.dod IS NULL THEN 1 WHEN STRFTIME('%j', patients.dod) - STRFTIME('%j', t2.charttime) > 2 * 365 THEN 1 ELSE 0 END) * 100 / COUNT(*) 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_diagnoses.short_title = 'preterm nec 2500+g') GROUP BY admissions.subject_id HAVING MIN(diagnoses_icd.charttime) = diagnoses_icd.charttime) AS t1 WHERE STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', t1.charttime) > 2 * 365) AS t2 JOIN patients ON t2.subject_id = patients.subject_id
|
### Instruction:
list the top three most common medications that patients were prescribed with within 2 months after being prescribed megestrol acetate until 2104.
### Response:
|
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'megestrol acetate' AND STRFTIME('%y', prescriptions.startdate) <= '2104') AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE STRFTIME('%y', prescriptions.startdate) <= '2104') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.startdate < t2.startdate AND DATETIME(t2.startdate) BETWEEN DATETIME(t1.startdate) AND DATETIME(t1.startdate, '+2 month') GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
when did patient 82132 receive the last iso-osmotic dextrose and metoprolol tartrate prescription at the same time during this month?
### Response:
|
SELECT t1.startdate FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'iso-osmotic dextrose' AND admissions.subject_id = 82132 AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'metoprolol tartrate' AND admissions.subject_id = 82132 AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')) AS t2 ON t1.subject_id = t2.subject_id WHERE DATETIME(t1.startdate) = DATETIME(t2.startdate) ORDER BY t1.startdate DESC LIMIT 1
|
### Instruction:
how many patients a year before underwent analgesics - narcotic analgesic during the same month following the diagnosis of acute respiratory failure - due to increased co2 production?
### Response:
|
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 failure - due to increased co2 production' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t1 JOIN (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', '-1 year')) AS t2 WHERE t1.diagnosistime < t2.treatmenttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.treatmenttime, 'start of month')
|
### Instruction:
how much did patient 005-73237 change his or her systemicmean last measured on the first intensive care unit visit compared to the value second to last measured on the first intensive care unit visit?
### Response:
|
SELECT (SELECT vitalperiodic.systemicmean FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-73237') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND NOT vitalperiodic.systemicmean IS NULL ORDER BY vitalperiodic.observationtime DESC LIMIT 1) - (SELECT vitalperiodic.systemicmean FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-73237') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND NOT vitalperiodic.systemicmean IS NULL ORDER BY vitalperiodic.observationtime DESC LIMIT 1 OFFSET 1)
|
### Instruction:
count the number of patients who were prescribed with potassium chloride crys er 20 meq po tbcr within 2 months after receiving a therapeutic antibacterials procedure since 4 years ago.
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'therapeutic antibacterials' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-4 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'potassium chloride crys er 20 meq po tbcr' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-4 year')) AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.treatmenttime) AND DATETIME(t1.treatmenttime, '+2 month')
|
### Instruction:
list flights from PITTSBURGH to NEWARK on monday morning
### 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 = 21 AND DATE_DAYalias0.month_number = 2 AND DATE_DAYalias0.year = 1991)) AND to_airport IN (SELECT AIRPORT_SERVICEalias1.airport_code FROM airport_service AS AIRPORT_SERVICEalias1 WHERE AIRPORT_SERVICEalias1.city_code IN (SELECT CITYalias1.city_code FROM city AS CITYalias1 WHERE CITYalias1.city_name = 'NEWARK'))) AND from_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'PITTSBURGH'))) AND departure_time BETWEEN 0 AND 1200)
|
### Instruction:
i want to fly from DETROIT to ST. PETERSBURG on NW and leave around 9am tell me what aircraft are used by this flight and tell me the flight number
### Response:
|
SELECT DISTINCT aircraft.aircraft_code, flight.flight_number FROM aircraft, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, equipment_sequence, flight WHERE (((flight.departure_time <= 930 AND flight.departure_time >= 830) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ST. PETERSBURG' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DETROIT' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND equipment_sequence.aircraft_code = aircraft.aircraft_code AND flight.aircraft_code_sequence = equipment_sequence.aircraft_code_sequence AND flight.airline_code = 'NW'
|
### Instruction:
what were the top five most frequent drugs that followed in the same month for patients who were receiving hemodialysis since 5 years ago?
### 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 = 'hemodialysis' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-5 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-5 year')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.drugstarttime AND DATETIME(t1.treatmenttime, 'start of month') = DATETIME(t2.drugstarttime, 'start of month') GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
give me the difference between the total of the input and the output of patient 26057 on 12/27/this year.
### Response:
|
SELECT (SELECT SUM(inputevents_cv.amount) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26057)) AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', inputevents_cv.charttime) = '12-27') - (SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26057)) AND DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', outputevents.charttime) = '12-27')
|
### Instruction:
what are the three most commonly prescribed medications for patients for whom magnesium sulfate 50 % (4 meq/ml) inj is also prescribed at the same time, in 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 = 'magnesium sulfate 50 % (4 meq/ml) inj' AND STRFTIME('%y', medication.drugstarttime) = '2104') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', medication.drugstarttime) = '2104') AS t2 ON t1.uniquepid = t2.uniquepid WHERE DATETIME(t1.drugstarttime) = DATETIME(t2.drugstarttime) GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
Will I be allowed to take both CAAS 248 and CAAS 426 at once in a semester ?
### Response:
|
SELECT COUNT(*) > 0 FROM course AS COURSE_0, course AS COURSE_1, course_offering AS COURSE_OFFERING_0, course_offering AS COURSE_OFFERING_1, course_prerequisite WHERE COURSE_OFFERING_1.semester = COURSE_OFFERING_0.semester AND COURSE_0.course_id = COURSE_OFFERING_0.course_id AND COURSE_0.department = 'CAAS' AND COURSE_0.number = 248 AND COURSE_1.course_id = COURSE_OFFERING_1.course_id AND COURSE_1.department = 'CAAS' AND COURSE_1.number = 426 AND (NOT ((COURSE_1.course_id = course_prerequisite.course_id AND COURSE_0.course_id = course_prerequisite.pre_course_id) OR (COURSE_1.course_id = course_prerequisite.pre_course_id AND COURSE_0.course_id = course_prerequisite.course_id)))
|
### Instruction:
how many patients with s/p cabg < 7 days were diagnosed during the same month during this year after the diagnosis of hepatic dysfunction - chronic?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 's/p cabg < 7 days' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hepatic dysfunction - chronic' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t2 WHERE t1.diagnosistime < t2.diagnosistime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.diagnosistime, 'start of month')
|
### Instruction:
is there a UA flight from BALTIMORE to SAN FRANCISCO on the morning of 8 27
### 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 (((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND date_day.day_number = 27 AND date_day.month_number = 8 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 0 AND 1200) AND flight.airline_code = 'UA'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.