instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: What courses are needed before I take PROSTHOD 635 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'PROSTHOD' AND COURSE_1.number = 635
### Instruction: when did patient 12775 first got the minimum of heart rate yesterday? ### Response:
SELECT chartevents.charttime FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12775)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY chartevents.valuenum, chartevents.charttime LIMIT 1
### Instruction: nonstop flights SEATTLE to KANSAS 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, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SEATTLE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'KANSAS CITY' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
### Instruction: when was the first time that patient 2514 had taken a d5w on 06/26/2105? ### Response:
SELECT inputevents_cv.charttime 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 = 2514)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd5w' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) = '2105-06-26' ORDER BY inputevents_cv.charttime LIMIT 1
### Instruction: indicate the daily minimum amount of arterial bp mean for patient 32154 in their first hospital visit. ### Response:
SELECT MIN(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 32154 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
### Instruction: is there a flight on UA from BOSTON to DENVER ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'UA'
### Instruction: , sql 2015. ### Response:
SELECT COUNT(*) FROM Posts AS p INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE p.PostTypeId = 1 AND YEAR(p.CreationDate) = 2015 AND MONTH(p.CreationDate) = 10 AND LOWER(u.Location) LIKE '%russia%' AND p.Id = (SELECT Id FROM Posts AS po WHERE po.OwnerUserId = u.Id AND po.PostTypeId = 1 AND YEAR(po.CreationDate) = 2015 AND MONTH(po.CreationDate) = 10 AND LOWER(u.Location) LIKE '%russia%' ORDER BY p.CreationDate LIMIT 1) HAVING COUNT(CASE WHEN p.Tags LIKE '%<sql>%' THEN 1 END) > 0
### Instruction: i'd like to see all flights from BALTIMORE to PHILADELPHIA ### 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 = 'BALTIMORE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: Top 100 users from Iran. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation FROM Users WHERE LOWER(Location) LIKE '%bangladesh%' OR UPPER(Location) LIKE '%BANGLADESH%' OR LOWER(Location) LIKE '%dhaka' OR UPPER(Location) LIKE '%DHAKA%' OR LOWER(Location) LIKE '%khulna' OR UPPER(Location) LIKE '%KHULNA%' OR LOWER(Location) LIKE '%buet' OR UPPER(Location) LIKE '%BUET%' OR LOWER(Location) LIKE '%kuet' OR UPPER(Location) LIKE '%KUET%' OR LOWER(Location) LIKE '%cuet' OR UPPER(Location) LIKE '%CUET%' ORDER BY Reputation DESC LIMIT 1000
### Instruction: show me nonstop flights from MONTREAL to ORLANDO ### 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 = 'MONTREAL' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ORLANDO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
### Instruction: Which courses are the prerequisites for CLIMATE 479 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'CLIMATE' AND COURSE_1.number = 479
### Instruction: Are there any courses that are only offered in Spring ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'EECS' AND semester.semester = 'Spring' AND (SELECT COUNT(DISTINCT SEMESTERalias1.semester) FROM course AS COURSEalias1 INNER JOIN course_offering ON COURSEalias1.course_id = course_offering.course_id INNER JOIN semester AS SEMESTERalias1 ON SEMESTERalias1.semester_id = course_offering.semester WHERE course.course_id = COURSEalias1.course_id) = 1
### Instruction: how many times did patient 017-58432 have an intake of ns ivf on 11/07/last year? ### Response:
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-58432')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'ns ivf' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '11-07'
### Instruction: list the nonstop flights from DENVER to WASHINGTON ### 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 = 'WASHINGTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
### Instruction: is there a flight on DL from BOSTON to DENVER ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'DL'
### Instruction: What are some software courses that are easier than DHYGRACK 685 ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE area.area LIKE '%software%' AND program_course.workload < (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM course AS COURSEalias1 INNER JOIN program_course AS PROGRAM_COURSEalias1 ON PROGRAM_COURSEalias1.course_id = COURSEalias1.course_id WHERE COURSEalias1.department = 'DHYGRACK' AND COURSEalias1.number = 685) ORDER BY program_course.workload
### Instruction: what was patient 12726's first time of taking .9% normal saline today? ### Response:
SELECT inputevents_cv.charttime 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 = 12726)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '.9% normal saline' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY inputevents_cv.charttime LIMIT 1
### Instruction: what are the top three most common diagnoses of people in 60 or above until 2104? ### Response:
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age >= 60) AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104' GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
### Instruction: what was the last value of the sao2 of patient 016-1459 on 02/24/this year? ### Response:
SELECT vitalperiodic.sao2 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-1459')) AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', vitalperiodic.observationtime) = '02-24' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
### Instruction: what are the DL flights from DALLAS to BOSTON ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'DL'
### Instruction: A Users total Rep ON META if there was no reputation cap. How much rep would you have if there was no reputation cap ### Response:
SELECT Users.Id AS "user_link", (SELECT SUM(CASE WHEN VoteTypeId = 1 THEN 15 WHEN VoteTypeId = 2 AND PostTypeId = 1 THEN 5 WHEN VoteTypeId = 2 AND PostTypeId = 2 THEN 10 WHEN VoteTypeId = 3 THEN -2 WHEN VoteTypeId = 9 THEN COALESCE(BountyAmount, 100) WHEN VoteTypeId = 15 THEN 2 WHEN VoteTypeId = 16 THEN 2 END) FROM Votes INNER JOIN Posts ON Posts.Id = Votes.PostId WHERE Posts.OwnerUserId = Users.Id) AS Reputation FROM Users WHERE Reputation > 0 ORDER BY Reputation DESC
### Instruction: since 955 days ago, what is average value of arterial bp [diastolic] for patient 31880? ### Response:
SELECT AVG(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31880)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime) >= DATETIME(CURRENT_TIME(), '-955 day')
### Instruction: tell me the top three most common procedures of patients with 50s until 2103? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 50 AND 59) AND STRFTIME('%y', procedures_icd.charttime) <= '2103' GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
### Instruction: show all flights from PITTSBURGH to SAN FRANCISCO ### 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 = 'PITTSBURGH' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: Does ENSCEN 172 have any prerequisites ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'ENSCEN' AND COURSE_1.number = 172
### Instruction: Users sorted by score per answer. Votes per answer (non-CW, with at least 400 answers to their credit) ### Response:
SELECT u.Id AS "user_link", u.Reputation AS "Rep", COUNT(a.Id) AS "Answers", SUM(a.Score) AS "Total Score", CAST(SUM(a.Score) AS FLOAT) / CAST(COUNT(a.Id) AS FLOAT) AS "Average" FROM Posts AS a, Users AS u WHERE a.OwnerUserId = u.Id AND a.PostTypeId = 2 AND a.CommunityOwnedDate IS NULL GROUP BY u.Id, u.Reputation HAVING COUNT(a.Id) > 10 ORDER BY CAST(SUM(a.Score) AS FLOAT) / CAST(COUNT(a.Id) AS FLOAT)
### Instruction: what was the drug that patient 007-15837 was prescribed for the last time using an periph iv route in 02/this year? ### Response:
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-15837')) AND medication.routeadmin = 'periph iv' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '02' ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: what was patient 3663's monthly average value of body weight since 5 years ago? ### Response:
SELECT AVG(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3663)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit wt' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime) >= DATETIME(CURRENT_TIME(), '-5 year') GROUP BY STRFTIME('%y-%m', chartevents.charttime)
### Instruction: what was the daily minimum amount of urine given to patient 002-38644 until 01/05/2104? ### Response:
SELECT MIN(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-38644')) AND intakeoutput.celllabel = 'urine' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2104-01-05' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
### Instruction: Before I take CSP 100 , which other courses must I complete ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'CSP' AND COURSE_1.number = 100
### Instruction: what is the daily average urine output that patient 003-17096 has had since 03/06/2105? ### Response:
SELECT AVG(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-17096')) AND intakeoutput.celllabel = 'urine' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2105-03-06' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
### Instruction: The total number of questions asked so far vs. time?. http://meta.stackexchange.com/questions/248396/how-can-i-get-stats-for-the-total-number-of-questions-asked-so-far-vs-time ### Response:
SELECT DATEADD(d, days, @lowest) AS "date", SUM(qcnt) OVER (ORDER BY days) AS Questions, SUM(acnt) OVER (ORDER BY days) AS Answers FROM (SELECT DATEDIFF(m, @lowest, creationdate) AS days, SUM(CASE WHEN PostTypeId = 1 THEN 1 ELSE 0 END) AS qcnt, SUM(CASE WHEN PostTypeId = 2 THEN 1 ELSE 0 END) AS acnt FROM Posts WHERE CreationDate >= @lowest GROUP BY DATEDIFF(m, @lowest, creationdate)) AS counts
### Instruction: when was the first time the heart rate measured in patient 13703 until 08/24/2102? ### Response:
SELECT chartevents.charttime FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13703)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) <= '2102-08-24' ORDER BY chartevents.charttime LIMIT 1
### Instruction: Closed questions by tag from the 1st month. ### Response:
SELECT YEAR(p.CreationDate), MONTH(p.CreationDate), AVG(CAST((JULIANDAY(ClosedDate) - JULIANDAY(p.CreationDate)) * 24.0 AS INT)) FROM Tags AS t INNER JOIN PostTags AS pt ON t.Id = pt.TagId INNER JOIN Posts AS P ON p.Id = pt.PostId WHERE t.TagName = '##TagNam##' AND NOT p.ClosedDate IS NULL AND YEAR(p.CreationDate) = 2013 AND MONTH(p.CreationDate) = 11 GROUP BY YEAR(p.CreationDate), MONTH(p.CreationDate) ORDER BY YEAR(p.CreationDate), MONTH(p.CreationDate)
### Instruction: can you list all flights leaving from ST. LOUIS and arriving in MILWAUKEE ### 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 = 'ST. LOUIS' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MILWAUKEE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: how many days have passed since the first time that patient 007-15837 had a eptifibatide intake on the current intensive care unit visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', intakeoutput.intakeoutputtime)) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-15837') AND patient.unitdischargetime IS NULL) AND intakeoutput.celllabel = 'eptifibatide' AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: AA from DENVER to MILWAUKEE ### 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 = 'MILWAUKEE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
### Instruction: i live in DENVER and i'd like to make a trip to PITTSBURGH ### 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
### Instruction: what is the daily maximum amount of bicarb drip that patient 5364 took on their first hospital visit? ### Response:
SELECT MAX(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 = 5364 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'bicarb drip' AND d_items.linksto = 'inputevents_cv') GROUP BY STRFTIME('%y-%m-%d', inputevents_cv.charttime)
### Instruction: had patient 4469 have a arterial bp [diastolic] greater than 68.0 during the first hospital encounter? ### Response:
SELECT COUNT(*) > 0 FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 4469 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') AND chartevents.valuenum > 68.0
### Instruction: have the arterial bp [diastolic] of patient 739 remained normal on the current intensive care unit visit? ### Response:
SELECT COUNT(*) > 0 FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 739) AND icustays.outtime IS NULL) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') AND chartevents.valuenum BETWEEN diastolic_bp_lower AND diastolic_bp_upper
### Instruction: looking for a flight from DC to MINNESOTA ### 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, state WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.state_code = 'DC' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code AND state.state_code = CITY_1.state_code AND state.state_name = 'MINNESOTA'
### Instruction: what flights does AA have from BOSTON to DALLAS ### 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 = 'DALLAS' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
### Instruction: count the number of times patient 016-2639 had been prescribed 1000 ml flex cont: dextrose-nacl 5-0.45 % iv soln the last year. ### Response:
SELECT COUNT(*) FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-2639')) AND medication.drugname = '1000 ml flex cont: dextrose-nacl 5-0.45 % iv soln' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
### Instruction: what is the monthly average emesis output that patient 015-23047 has had since 12/27/2105? ### Response:
SELECT AVG(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-23047')) AND intakeoutput.celllabel = 'emesis' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2105-12-27' GROUP BY STRFTIME('%y-%m', intakeoutput.intakeoutputtime)
### Instruction: what flights depart from PITTSBURGH and arrive in OAKLAND california ### 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 = 'PITTSBURGH' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'OAKLAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: how many days ago was the first time patient 030-34260 was diagnosed with acute respiratory failure - due to neurological process in their current hospital visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnosis.diagnosistime)) FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-34260' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'acute respiratory failure - due to neurological process' ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: i'd like to arrange a flight from PITTSBURGH to ATLANTA ### 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 = 'PITTSBURGH' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: all flights from PITTSBURGH to PHILADELPHIA ### 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 = 'PITTSBURGH' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: how many hours have it been since patient 97395 had the first idio periph neurpthy nos diagnosis during this hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnoses_icd.charttime)) FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'idio periph neurpthy nos') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97395 AND admissions.dischtime IS NULL) ORDER BY diagnoses_icd.charttime LIMIT 1
### Instruction: Top 100 posts with the best anonymous/low-rep feedback. ### Response:
SELECT SUM(CASE WHEN f.VoteTypeId = 2 THEN 1 ELSE -1 END) AS Score, SUM(CASE WHEN f.VoteTypeId = 2 THEN 1 ELSE 0 END) AS Helpful, SUM(CASE WHEN f.VoteTypeId = 3 THEN 1 ELSE 0 END) AS Unhelpful, f.PostId AS "post_link", p.OwnerUserId AS "user_link" FROM PostFeedback AS f INNER JOIN Posts AS p ON p.Id = f.PostId INNER JOIN PostTags AS pt ON pt.PostId = f.PostId WHERE f.VoteTypeId IN (2, 3) AND pt.TagId = 202 GROUP BY f.PostId, p.OwnerUserId ORDER BY Score DESC LIMIT 100
### Instruction: when did patient 005-4471 first had the tube feeding residual discarded (ml) output since 08/08/2102? ### Response:
SELECT intakeoutput.intakeoutputtime FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-4471')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'tube feeding residual discarded (ml)' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2102-08-08' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: Who was the teacher of Michele Owen in ASIANPAM 548 ? ### Response:
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN student_record ON student_record.offering_id = offering_instructor.offering_id INNER JOIN student ON student.student_id = student_record.student_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.department = 'ASIANPAM' AND course.number = 548 AND student.firstname LIKE 'Michele' AND student.lastname LIKE 'Owen'
### Instruction: what is the monthly average intake of vasopressin (ml): that patient 031-3355 is getting since 34 months ago? ### Response:
SELECT AVG(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-3355')) AND intakeoutput.celllabel = 'vasopressin (ml):' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-34 month') GROUP BY STRFTIME('%y-%m', intakeoutput.intakeoutputtime)
### Instruction: had patient 016-9636 excreted output amt-chest tube a in 12/this year? ### Response:
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-9636')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output amt-chest tube a' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', intakeoutput.intakeoutputtime) = '12'
### Instruction: For BCS 232 what are the classes needed to be taken ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'BCS' AND COURSE_1.number = 232
### Instruction: what is the yearly minimum of ct meds output of patient 016-27397 since 09/01/2105? ### Response:
SELECT MIN(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-27397')) AND intakeoutput.celllabel = 'ct meds' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2105-09-01' GROUP BY STRFTIME('%y', intakeoutput.intakeoutputtime)
### Instruction: what was the daily average value of weight for patient 27964 since 2105? ### Response:
SELECT AVG(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27964)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit wt' AND d_items.linksto = 'chartevents') AND STRFTIME('%y', chartevents.charttime) >= '2105' GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
### Instruction: a flight on CO leaving BOSTON and going to DENVER ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'CO'
### Instruction: Which human computer interaction courses are easier than PUBPOL 683 ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE area.area LIKE '%human computer interaction%' AND program_course.workload < (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM course AS COURSEalias1 INNER JOIN program_course AS PROGRAM_COURSEalias1 ON PROGRAM_COURSEalias1.course_id = COURSEalias1.course_id WHERE COURSEalias1.department = 'PUBPOL' AND COURSEalias1.number = 683) ORDER BY program_course.workload
### Instruction: whats patient 12775 minimum arterial bp [systolic] during yesterday? ### Response:
SELECT MIN(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12775)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: when was the first time that patient 015-91239 on this month/31 had the minimum heartrate value. ### Response:
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-91239')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', vitalperiodic.observationtime) = '31' ORDER BY vitalperiodic.heartrate, vitalperiodic.observationtime LIMIT 1
### Instruction: High Reputation Users Who are Also Tenacious. ### Response:
WITH total_users AS (SELECT tu_count = COUNT(*) FROM Users), users_rep_x AS (SELECT ru_count = COUNT(*) FROM Users AS u WHERE u.Reputation > 1000) SELECT DISTINCT (SELECT tu_count FROM total_users) AS "total_users", (SELECT ru_count FROM users_rep_x) AS "users_rep_>_x", CAST((CAST((SELECT ru_count FROM users_rep_x) AS FLOAT(10, 5)) / CAST(((SELECT tu_count FROM total_users) / 100) AS FLOAT(10, 5))) AS FLOAT(10, 5)) AS "repu_of_totu_in_%" FROM Users AS u WHERE u.Reputation > 2500
### Instruction: how many hours have it been since the first diagnosis of atrial fibrillation - with rapid ventricular response in patient 027-85328 on the current hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnosis.diagnosistime)) FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-85328' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'atrial fibrillation - with rapid ventricular response' ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: please show me the return flight number from TORONTO to ST. PETERSBURG ### 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 = 'TORONTO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ST. PETERSBURG' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: Percent of users whose first post was a question of score > 0, out of all users who have posted. ### Response:
WITH QA AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY OwnerUserId ORDER BY OwnerUserId, CreationDate) AS PostOrder FROM Posts WHERE PostTypeId IN (1, 2) AND CommunityOwnedDate IS NULL AND DeletionDate IS NULL) SELECT ROUND(100.0 * num.NFirstGoodQ / denom.NPosters, 2) FROM (SELECT COUNT(Id) AS NPosters FROM Users WHERE Id IN (SELECT DISTINCT OwnerUserId FROM QA)) AS denom JOIN LATERAL (SELECT COUNT(DISTINCT OwnerUserId) AS NFirstGoodQ FROM QA WHERE PostOrder = 1 AND PostTypeId = 2 AND Score > 0) AS num
### Instruction: when was the last time patient 007-15837 had a output (ml)-urethral catheter output during the previous day. ### Response:
SELECT intakeoutput.intakeoutputtime FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-15837')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output (ml)-urethral catheter' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: Which courses has Prof. Eduardo Matos-martin been assigned to teach for the coming year ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Eduardo Matos-martin%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester_id = course_offering.semester AND ((semester.semester = 'FA' AND semester.year = 2016) OR (semester.semester = 'WN' AND semester.year = 2017))
### Instruction: count the number of times patient 030-42006 has been given prbcs on 07/07/this year. ### Response:
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-42006')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'prbcs' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '07-07'
### Instruction: show me DL flights from DALLAS to DENVER ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'DL'
### Instruction: since 2104, what was the four most frequent procedure for patients 20s? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 20 AND 29) AND STRFTIME('%y', procedures_icd.charttime) >= '2104' GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
### Instruction: had patient 23224's heart rate ever been less than 108.0 degrees until 853 days ago? ### Response:
SELECT COUNT(*) > 0 FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23224)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND chartevents.valuenum < 108.0 AND DATETIME(chartevents.charttime) <= DATETIME(CURRENT_TIME(), '-853 day')
### Instruction: Which Winter courses are only offered then ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'EECS' AND semester.semester = 'Winter' AND (SELECT COUNT(DISTINCT SEMESTERalias1.semester) FROM course AS COURSEalias1 INNER JOIN course_offering ON COURSEalias1.course_id = course_offering.course_id INNER JOIN semester AS SEMESTERalias1 ON SEMESTERalias1.semester_id = course_offering.semester WHERE course.course_id = COURSEalias1.course_id) = 1
### Instruction: tell me the name of the intake that patient 30826 had for the last time on this month/27? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT inputevents_cv.itemid 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 = 30826)) AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', inputevents_cv.charttime) = '27' ORDER BY inputevents_cv.charttime DESC LIMIT 1)
### Instruction: what was the daily maximum amount of foley given to patient 53176 since 12/28/2105? ### Response:
SELECT MAX(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 = 53176)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'foley' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m-%d', outputevents.charttime) >= '2105-12-28' GROUP BY STRFTIME('%y-%m-%d', outputevents.charttime)
### Instruction: what was the daily average amount of drain out #2 jackson pratt given to patient 19144 on the first icu visit? ### Response:
SELECT AVG(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 = 19144) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'drain out #2 jackson pratt' AND d_items.linksto = 'outputevents') GROUP BY STRFTIME('%y-%m-%d', outputevents.charttime)
### Instruction: Top Android Contributors in Spain && Germany. ### Response:
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", u.Location, COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE (LOWER(Location) LIKE '%germany%' OR LOWER(Location) LIKE '%spain%') AND TagName = 'android' GROUP BY u.Id, TagName, Location) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
### Instruction: Me as a review task. ### Response:
SELECT t.Id AS "postlink", 'site://review/' + CASE t.ReviewTaskTypeId WHEN 1 THEN 'suggested-edits' WHEN 2 THEN 'close' WHEN 3 THEN 'low-quality-posts' WHEN 4 THEN 'first-posts' WHEN 5 THEN 'late-answers' WHEN 6 THEN 'reopen' WHEN 10 THEN 'triage' WHEN 11 THEN 'helper' END + '/' + CAST(t.Id AS TEXT) + '|' + c.Name, p.Id AS "post_link" FROM ReviewTasks AS t JOIN Posts AS p ON t.PostId = p.Id JOIN ReviewTaskTypes AS c ON t.ReviewTaskTypeId = c.Id WHERE p.OwnerUserId = '##UserId##' ORDER BY c.Name DESC, t.Id
### Instruction: i'd like to see all the flights from BOSTON to PHILADELPHIA ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: What are the prerequisites for ENS 360 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'ENS' AND COURSE_1.number = 360
### Instruction: fasting plasma glucose 100 _ 125 mg / dl, and / or hemoglobin _ a1c between 5.5 and 6.4 % , and / or post _ load glucose between 140 and 199 mg / dl on a 2 _ hour oral glucose tolerance test ( ogtt ) ### Response:
SELECT * FROM table_dev_29 WHERE (fasting_plasma_glucose >= 100 AND fasting_plasma_glucose <= 125) OR (hemoglobin_a1c_hba1c >= 5.5 AND hemoglobin_a1c_hba1c <= 6.4) OR (post_load_glucose >= 140 AND post_load_glucose <= 199)
### Instruction: are patient 6196's temperature c (calc) normal until 07/2103? ### Response:
SELECT COUNT(*) > 0 FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6196)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'temperature c (calc)' AND d_items.linksto = 'chartevents') AND chartevents.valuenum BETWEEN temperature_lower AND temperature_upper AND STRFTIME('%y-%m', chartevents.charttime) <= '2103-07'
### Instruction: what was the daily average dose of volume (ml) lipids that patient 030-556 was taking until 542 days ago? ### Response:
SELECT AVG(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-556')) AND intakeoutput.celllabel = 'volume (ml) lipids' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-542 day') GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
### Instruction: count the number of times patient 31880 has had a void output on 01/07/last year. ### Response:
SELECT COUNT(*) 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 = 31880)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'void' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', outputevents.charttime) = '01-07'
### Instruction: I understand that Prof. Susanne Vees-gulani taught MATH 513 in the Spring 2018 semester , is that correct ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'MATH' AND course.number = 513 AND instructor.name LIKE '%Susanne Vees-gulani%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'Spring' AND semester.semester_id = course_offering.semester AND semester.year = 2018
### Instruction: Over the next year , what classes will Prof. Vikramaditya Khanna be teaching ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Vikramaditya Khanna%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester_id = course_offering.semester AND ((semester.semester = 'FA' AND semester.year = 2016) OR (semester.semester = 'WN' AND semester.year = 2017))
### Instruction: has patient 030-8973 been given any fat emulsion 20% intake in 12/last year? ### Response:
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-8973')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'fat emulsion 20%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', intakeoutput.intakeoutputtime) = '12'
### Instruction: Questions ripe for deletion: Unanswered, downvoted, and closed questions. Want to exercise your democratic 10k rights? Can't find questions to delete? Want to give that barrel a good ol' bottom-scraping? Behold, the worst questions ever. Sorted by score and how long they've been closed. ### Response:
SELECT q.Id FROM Posts AS q WHERE q.PostTypeId = 1 AND q.LastEditDate < DATEADD(d, -60, GETDATE()) AND q.ClosedDate IS NULL AND q.AcceptedAnswerId IS NULL AND (q.AnswerCount IS NULL OR q.AnswerCount = 0 OR NOT EXISTS(SELECT Id FROM Posts AS a WHERE a.PostTypeId = 2 AND a.ParentId = q.Id AND a.Score > 0)) ORDER BY q.Id
### Instruction: find me flights that are nonstop between BOSTON and DALLAS ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
### Instruction: What courses are required before GEOSCI 555 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'GEOSCI' AND COURSE_1.number = 555
### Instruction: what was the monthly minimum amount of output amt-blake drain given to patient 007-4119 since 89 months ago? ### Response:
SELECT MIN(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-4119')) AND intakeoutput.celllabel = 'output amt-blake drain' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-89 month') GROUP BY STRFTIME('%y-%m', intakeoutput.intakeoutputtime)
### Instruction: Publicity badges awarded within a given period. ### Response:
SELECT UserId AS "user_link", SUM(CASE WHEN Name = 'Publicist' THEN 1 ELSE 0 END) AS Publicist, SUM(CASE WHEN Name = 'Booster' THEN 1 ELSE 0 END) AS Booster, SUM(CASE WHEN Name = 'Announcer' THEN 1 ELSE 0 END) AS Announcer, SUM(CASE WHEN (Name = 'Announcer') OR (Name = 'Booster') OR (Name = 'Publicist') THEN 1 ELSE 0 END) AS total FROM Badges WHERE Date >= '##Date1?2019-12-12##' AND Date <= '##Date2?2019-12-14##' GROUP BY UserId ORDER BY Publicist DESC, Booster DESC, Announcer DESC, total DESC LIMIT 200
### Instruction: how many hours has elapsed since the last time patient 006-105495 received a d5w intake on the current intensive care unit visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', intakeoutput.intakeoutputtime)) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-105495') AND patient.unitdischargetime IS NULL) AND intakeoutput.celllabel = 'd5w' AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: what is the overall intake of sc 26 po that patient 23070 has received until 12/20/2105? ### Response:
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 = 23070)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sc 26 po' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) <= '2105-12-20'
### Instruction: Do I need to take courses before taking NERS 524 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'NERS' AND COURSE_1.number = 524
### Instruction: apache-camel questions since Feb 2020. ### Response:
SELECT Questions.Id AS "post_link", Questions.Title, Questions.AnswerCount, Questions.ViewCount, Questions.FavoriteCount, Questions.Score, Questions.LastActivityDate, Questions.CreationDate FROM Posts AS Questions INNER JOIN PostTags ON PostTags.PostId = Questions.Id INNER JOIN Tags ON Tags.Id = PostTags.TagId AND Tags.TagName IN ('apache-camel') WHERE Questions.CreationDate >= '2020-02-01' GROUP BY Questions.Id, Questions.Title, Questions.AnswerCount, Questions.ViewCount, Questions.FavoriteCount, Questions.Score, Questions.LastActivityDate, Questions.CreationDate ORDER BY Questions.CreationDate DESC LIMIT 100
### Instruction: A list of the top 20 users with the highest average answer score excluding community wiki / closed posts or users with less than 10 answers. A list of the top 500 users with the highest average answer score excluding community wiki / closed posts or users with less than 10 answers ### Response:
SELECT Users.Id AS "user_link", COUNT(Posts.Id) AS Answers, CAST(AVG(CAST(Score AS FLOAT)) AS FLOAT(6, 2)) AS "average_answer_score" FROM Posts INNER JOIN Users ON Users.Id = OwnerUserId WHERE PostTypeId = 2 AND CommunityOwnedDate IS NULL AND ClosedDate IS NULL GROUP BY Users.Id, DisplayName HAVING COUNT(Posts.Id) > 10 ORDER BY 'average_answer_score' DESC LIMIT 20
### Instruction: what was the first medication prescribed to patient 006-158759 in 03/last year via intravenous route? ### Response:
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-158759')) AND medication.routeadmin = 'intravenous' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', medication.drugstarttime) = '03' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: Posts by month, for all math.se moderator election nominees. ### Response:
SELECT Users.DisplayName, COUNT(*) AS Posts, CAST(TIME_TO_STR(p.CreationDate, '%Y.%m.%d') AS TEXT(7)) AS Month FROM Posts AS p JOIN Users ON Users.Id = p.OwnerUserId WHERE p.OwnerUserId IN (8173, 62278, 8348, 15416, 45760, 23353, 21674, 14082, 25805, 34662, 12952) GROUP BY CAST(TIME_TO_STR(p.CreationDate, '%Y.%m.%d') AS TEXT(7)), Users.DisplayName
### Instruction: baseline hgb < 11.7 g / dl in female , or < 13 g / dl in male ; lymphopenia ( < 1000 lymphocytes / mcl ) or leukopenia ( < 3000 total leukocytes / mcl ) , or an absolute cd4 count < 500 , or platelets < 150000 ### Response:
SELECT * FROM table_dev_30 WHERE (baseline_hemoglobin_hgb < 11.7 AND gender = 'female') OR (baseline_hemoglobin_hgb < 13 AND gender = 'male') OR lymphopenia < 1000 OR leukopenia < 3000 OR cd4_count < 500 OR platelets < 150000