instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: When Annette Le took HEBREW 568 , who taught it ? ### 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 = 'HEBREW' AND course.number = 568 AND student.firstname LIKE 'Annette' AND student.lastname LIKE 'Le'
### Instruction: when was last time patient 027-165214 was measured with a systemicmean less than 112.0 during the previous day? ### 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 = '027-165214')) AND vitalperiodic.systemicmean < 112.0 AND NOT vitalperiodic.systemicmean IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY vitalperiodic.observationtime DESC LIMIT 1
### Instruction: In Fall terms , when is 567 available ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.start_time, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 567 AND semester.semester IN ('SP', 'Fall', 'SS') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: tell me the total amount of foley output on this month/29 for patient 51858. ### Response:
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 = 51858)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'foley' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', outputevents.charttime) = '29'
### Instruction: Questions posted with top 10 most view counts given a tag and the questions' duration. ### Response:
SELECT p1.Title AS "Question Title", 'http://www.stackoverflow.com/questions/' + CAST(p1.Id AS TEXT) AS "URL", p1.ViewCount AS "Number of Views" FROM Posts AS p1, PostTags AS ptags1, Tags AS t1, PostTypes AS ptypes1 WHERE p1.PostTypeId = ptypes1.Id AND ptypes1.Id = 1 AND p1.Id = ptags1.PostId AND ptags1.TagId = t1.Id AND t1.TagName = '##TagName##' AND p1.CreationDate >= '##startdate##' AND p1.CreationDate <= '##enddate##' ORDER BY 'NUMBER OF VIEWS' DESC LIMIT 10
### Instruction: what is the total amount of input that patient 027-151154 received on 12/27/this year. ### Response:
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-151154')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '12-27'
### Instruction: what was the medication that patient 035-2057 was prescribed for the first time through the iv push route in 09/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 = '035-2057')) AND medication.routeadmin = 'iv push' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '09' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: when did patient 50065 receive direct antigen test for herpes simplex virus types 1 & 2 microbiology test the first time in 04/this year? ### Response:
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 50065) AND microbiologyevents.spec_type_desc = 'direct antigen test for herpes simplex virus types 1 & 2' AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', microbiologyevents.charttime) = '04' ORDER BY microbiologyevents.charttime LIMIT 1
### Instruction: in 2101, what was the monthly average weight of patient 3369? ### 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 = 3369)) 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) = '2101' GROUP BY STRFTIME('%y-%m', chartevents.charttime)
### Instruction: how many days has passed since patient 97395 received his last diagnosis of drug dermatitis nos in their current hospital visit? ### Response:
SELECT 1 * (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 = 'drug dermatitis 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 DESC LIMIT 1
### Instruction: what was the daily minimum amount of number of bowel movements given to patient 028-22327 since 22 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 = '028-22327')) AND intakeoutput.celllabel = 'number of bowel movements' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-22 month') GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
### Instruction: what was the yearly maximum value of weight for patient 25668 until 2101? ### Response:
SELECT MAX(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 = 25668)) 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) <= '2101' GROUP BY STRFTIME('%y', chartevents.charttime)
### Instruction: MFG 470 has never been taught by whom ? ### Response:
SELECT DISTINCT name FROM instructor WHERE NOT name IN (SELECT INSTRUCTORalias1.name FROM course AS COURSEalias0 INNER JOIN course_offering AS COURSE_OFFERINGalias0 ON COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id INNER JOIN offering_instructor AS OFFERING_INSTRUCTOR ON OFFERING_OFFERING_ID = COURSE_OFFERINGalias0.offering_id INNER JOIN instructor AS INSTRUCTORalias1 ON offering_instructor_id = INSTRUCTORalias1.instructor_id WHERE COURSEalias0.department = 'MFG' AND COURSEalias0.number = 470)
### Instruction: Are there theory courses that are easier than ENGR 490 ? ### 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 '%theory%' 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 = 'ENGR' AND COURSEalias1.number = 490) ORDER BY program_course.workload
### Instruction: when, for the last time until 09/2104, patient 031-16123 received sputum, tracheal specimen microbiology test? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-16123')) AND microlab.culturesite = 'sputum, tracheal specimen' AND STRFTIME('%y-%m', microlab.culturetakentime) <= '2104-09' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: flights from BALTIMORE 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 = 'BALTIMORE' 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: count the number of times patient 030-21071 got the indwelling catheter on last month/21. ### 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-21071')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'indwelling catheter' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '21'
### Instruction: For 867 , what times of the week will it be offered ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.start_time, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday FROM semester INNER JOIN course_offering ON semester.semester_id = course_offering.semester INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.department = 'EECS' AND course.number = 867 AND semester.semester = 'FA' AND semester.year = 2016
### Instruction: when did patient 030-42006 last have an intake, on this month/22? ### 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 = '030-42006')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '22' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: i need to fly leaving PHILADELPHIA 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 = 'PHILADELPHIA' 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: return me the number of papers written by ' H. V. Jagadish ' and ' Divesh Srivastava ' before 2000 . ### Response:
SELECT COUNT(DISTINCT (publication.title)) FROM author AS AUTHOR_0, author AS AUTHOR_1, publication, writes AS WRITES_0, writes AS WRITES_1 WHERE AUTHOR_0.name = 'H. V. Jagadish' AND AUTHOR_1.name = 'Divesh Srivastava' AND publication.year < 2000 AND WRITES_0.aid = AUTHOR_0.aid AND WRITES_0.pid = publication.pid AND WRITES_1.aid = AUTHOR_1.aid AND WRITES_1.pid = publication.pid
### Instruction: what flights go from PHOENIX 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, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHOENIX' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SALT LAKE CITY' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: when did the last microbiology test of patient 031-24513 in 03/last year be performed? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-24513')) AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microlab.culturetakentime) = '03' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: when did patient 005-77687 get intakes for the first time on last month/25? ### 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-77687')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '25' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: how many patients have received a opn lft hemicolectmy nec procedure two times until 1 year ago? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, COUNT(*) AS c1 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 lft hemicolectmy nec') AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 = 2
### Instruction: count the number of patients who have already received the opn tricus valvuloplasty two or more times in 2105. ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, COUNT(*) AS c1 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 tricus valvuloplasty') AND STRFTIME('%y', procedures_icd.charttime) = '2105' GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 >= 2
### Instruction: until 03/2103, when was the first time patient 035-18116 was prescribed magnesium sulfate 2 gm/50 ml ivpb? ### Response:
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '035-18116')) AND medication.drugname = 'magnesium sulfate 2 gm/50 ml ivpb' AND STRFTIME('%y-%m', medication.drugstarttime) <= '2103-03' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: show me all flight from SAN FRANCISCO to OAKLAND ### 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 = 'SAN FRANCISCO' 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: show me all the flights from PHILADELPHIA to NEWARK ### 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 = 'PHILADELPHIA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NEWARK' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: information of a flight from ATLANTA 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 = 'ATLANTA' 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: tell me the last time patient 031-23724 took a microbiology test in 08/last year? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-23724')) AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microlab.culturetakentime) = '08' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: how many patients had received a aortocor bypas-3 cor art procedure two times until 2 years ago? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, COUNT(*) AS c1 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 = 'aortocor bypas-3 cor art') AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 = 2
### Instruction: how many patients until 3 years ago have had opn/oth rep aortic valve two or more times? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, COUNT(*) AS c1 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') AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 >= 2
### Instruction: how many patients until 3 years ago have received gastric tube irrigat nec two or more times? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, COUNT(*) AS c1 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 = 'gastric tube irrigat nec') AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 >= 2
### Instruction: i need to fly between PHILADELPHIA and 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 = 'PHILADELPHIA' 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: Combined PostHistory (question and all the answers). ### Response:
SELECT p.Id, CASE WHEN (p.ParentId IS NULL) THEN 'Question' ELSE 'Answer' END, ph.PostHistoryTypeId, CASE ph.PostHistoryTypeId WHEN 1 THEN 'Initial Title' WHEN 2 THEN 'Initial Body' WHEN 3 THEN 'Initial Tags' WHEN 4 THEN 'Edit Title' WHEN 5 THEN 'Edit Body' WHEN 6 THEN 'Edit Tags' WHEN 7 THEN 'Initial Title' WHEN 8 THEN 'Initial Body' WHEN 9 THEN 'Initial Tags' END, ph.UserId AS "user_link", ph.Comment FROM PostHistory AS ph INNER JOIN Posts AS p ON p.Id = ph.PostId WHERE COALESCE(p.ParentId, p.Id) = '##qid?85211##' ORDER BY ph.Id DESC
### Instruction: what were the drugs added to patient 49176 today compared with the ones yesterday? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 49176) AND DATETIME(prescriptions.startdate, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 49176) AND DATETIME(prescriptions.startdate, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: show me all flights from INDIANAPOLIS to MONTREAL ### 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 = 'INDIANAPOLIS' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MONTREAL' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: Do you know which class Dr. Yoshihiro Mochizuki has taught previously ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor WHERE course_offering.semester < (SELECT SEMESTERalias0.semester_id FROM semester AS SEMESTERalias0 WHERE SEMESTERalias0.semester = 'WN' AND SEMESTERalias0.year = 2016) AND course.course_id = course_offering.course_id AND instructor.name LIKE '%Yoshihiro Mochizuki%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: when did patient 007-15837 first get a volume (ml) amiodarone intake in a day before? ### 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 '%intake%' AND intakeoutput.celllabel = 'volume (ml) amiodarone' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: what was the name of the output the last time patient 030-21071 had on last month/21? ### Response:
SELECT intakeoutput.celllabel FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-21071')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '21' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: show departures and arrivals in ATLANTA for american airlines ### 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 (flight.to_airport = AIRPORT_SERVICE_0.airport_code AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'ATLANTA') OR (flight.from_airport = AIRPORT_SERVICE_1.airport_code AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA')
### Instruction: what is patient 3369's yearly maximum weight since 5 years ago? ### Response:
SELECT MAX(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 = 3369)) 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', chartevents.charttime)
### Instruction: patient 013-29301 had received a laxatives - psyllium (metamucil, polycarbophil) procedure in other hospitals since 2102? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '013-29301' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '013-29301' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'laxatives - psyllium (metamucil, polycarbophil)' AND STRFTIME('%y', treatment.treatmenttime) >= '2102'
### Instruction: how the percentile is the glucose value of 83.0 among patients of the same age as patient 42473 on the current hospital visit? ### Response:
SELECT DISTINCT t1.c1 FROM (SELECT labevents.valuenum, PERCENT_RANK() OVER (ORDER BY labevents.valuenum) AS c1 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'glucose') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age = (SELECT admissions.age FROM admissions WHERE admissions.subject_id = 42473 AND admissions.dischtime IS NULL))) AS t1 WHERE t1.valuenum = 83.0
### Instruction: What is the Spring term schedule for 555 ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.start_time, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 555 AND semester.semester IN ('SP', 'Spring', 'SS') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: i need a flight from PITTSBURGH to NEW YORK ### 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 = 'NEW YORK' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: Which teachers have not taught ENVIRON 479 ? ### Response:
SELECT DISTINCT name FROM instructor WHERE NOT name IN (SELECT INSTRUCTORalias1.name FROM course AS COURSEalias0 INNER JOIN course_offering AS COURSE_OFFERINGalias0 ON COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id INNER JOIN offering_instructor AS OFFERING_INSTRUCTOR ON OFFERING_OFFERING_ID = COURSE_OFFERINGalias0.offering_id INNER JOIN instructor AS INSTRUCTORalias1 ON offering_instructor_id = INSTRUCTORalias1.instructor_id WHERE COURSEalias0.department = 'ENVIRON' AND COURSEalias0.number = 479)
### Instruction: Best commenters by average comment score. Users ranked by average comment score. ### Response:
SELECT UserId AS "user_link", SUM(Score) AS Score, COUNT(Score) AS Comments, ROUND(AVG(CAST(Score AS FLOAT)), 3) AS AvgScore, ROUND(STDEV(Score), 3) AS StdDev, MAX(Score) AS TopScore, ROUND((SUM(Score) - MAX(Score)) / (COUNT(Score) - 1.0), 3) AS AvgScoreWOTop FROM Comments INNER JOIN Users ON Users.Id = UserId WHERE UserId = 479156 AND Score < 20 GROUP BY UserId, Users.Reputation HAVING COUNT(Score) >= '##MinComments:int?20##' ORDER BY AvgScore DESC LIMIT 25
### Instruction: Usu rios vs. Votantes no SOpt. ### Response:
SELECT (SELECT COUNT(*) FROM Users) AS TotalUsuarios, (SELECT COUNT(*) FROM Users WHERE Reputation >= 15) AS PodemVotar, (SELECT COUNT(*) FROM Users WHERE UpVotes + DownVotes > 0) AS Votaram, (SELECT COUNT(*) FROM Users WHERE UpVotes + DownVotes > 9) AS VotaramDezVezes, (SELECT COUNT(*) FROM Users WHERE Reputation >= 200) AS UsuariosAtivos, (SELECT COUNT(*) FROM Users WHERE Reputation >= 200 AND UpVotes + DownVotes > 0) AS AtivosVotaram, (SELECT COUNT(*) FROM Users WHERE Reputation >= 200 AND UpVotes + DownVotes > 9) AS AtivosVotaramDezVezes
### Instruction: for the first time in 03/this year, when was patient 021-79544 prescribed for lantus? ### Response:
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-79544')) AND medication.drugname = 'lantus' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '03' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: what was the name of the output, which patient 015-59552 had last on this month/22? ### Response:
SELECT intakeoutput.celllabel FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-59552')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '22' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: what was the name of the intake that patient 005-77687 on last month/30 first had? ### Response:
SELECT intakeoutput.celllabel FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-77687')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '30' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: indicate the daily average amount of sao2 for patient 594 on the last hospital visit. ### 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 = 594 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sao2' AND d_items.linksto = 'chartevents') GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
### Instruction: how many days has it been since patient 006-14121 was first diagnosed with s/p exploratory laparotomy in the in the current hospital encounter? ### 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 = '006-14121' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 's/p exploratory laparotomy' ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: compare to yesterday what was new in the prescription of patient 14671 today? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14671) AND DATETIME(prescriptions.startdate, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14671) AND DATETIME(prescriptions.startdate, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: show me all flights from PITTSBURGH 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 = 'PITTSBURGH' 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
### Instruction: since 09/2104, has there been any organism found in patient 025-28600's last sputum, tracheal specimen microbiology test? ### Response:
SELECT COUNT(*) > 0 FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-28600')) AND microlab.culturesite = 'sputum, tracheal specimen' AND STRFTIME('%y-%m', microlab.culturetakentime) >= '2104-09' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: what was the first urine incontinence output time of patient 002-39753 until 12/03/2105? ### 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 = '002-39753')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'urine incontinence' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2105-12-03' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: i would like to fly from PHILADELPHIA 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 = 'PHILADELPHIA' 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
### Instruction: show flights between TORONTO and 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 = 'TORONTO' 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: what is the monthly minimum amount of stool out stool that patient 61339 had until 71 months ago? ### Response:
SELECT MIN(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 = 61339)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'stool out stool' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime) <= DATETIME(CURRENT_TIME(), '-71 month') GROUP BY STRFTIME('%y-%m', outputevents.charttime)
### Instruction: For 619 , when does it meet in the Summer ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.start_time, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday FROM semester INNER JOIN course_offering ON semester.semester_id = course_offering.semester INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.department = 'EECS' AND course.number = 619 AND semester.semester = 'Summer' AND semester.year = 2016
### Instruction: what are my choices of flights from LAS VEGAS to NEW YORK ### 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 = 'LAS VEGAS' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NEW YORK' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: show me the flights from PHILADELPHIA 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 = 'PHILADELPHIA' 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
### Instruction: nonstop flights DENVER 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 = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
### Instruction: what was the first height of patient 17667 this month? ### Response:
SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17667)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY chartevents.charttime LIMIT 1
### Instruction: how many days has passed since the last time that patient 005-87465 had undergone a anticonvulsant - levetiracetam procedure during their current hospital encounter? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-87465' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'anticonvulsant - levetiracetam' ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: what was the last urine out foley-output time of patient 59049 since 02/24/2105? ### Response:
SELECT outputevents.charttime 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 = 59049)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'urine out foley' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m-%d', outputevents.charttime) >= '2105-02-24' ORDER BY outputevents.charttime DESC LIMIT 1
### Instruction: 5 in 30 minutes or less. ### Response:
SELECT q.Id AS "post_link", q.CreationDate, q.OwnerUserId AS "user_link", COUNT(a.Id) AS "answersin30" FROM Posts AS q INNER JOIN Posts AS a ON q.Id = a.ParentId AND a.PostTypeId = 2 AND CAST((JULIANDAY(CreationDate) - JULIANDAY(q.CreationDate)) * 1440.0 AS INT) <= 60 WHERE q.PostTypeId = 1 AND q.ClosedDate IS NULL AND q.CreationDate > '1 Jan 2014' GROUP BY q.Id, q.CreationDate, q.OwnerUserId HAVING COUNT(a.Id) >= 5 ORDER BY q.CreationDate
### Instruction: Posts grouped by time of the day for specific user. ### Response:
SELECT CAST(TIME_TO_STR(CreationDate, '%-HOUR') AS TEXT) + '-' + CAST(TIME_TO_STR(CreationDate, '%-HOUR') + 1 AS TEXT) + ' UTC' AS time_of_the_day, CAST(TIME_TO_STR(CreationDate, '%-HOUR') + 5.5 AS TEXT) + '-' + CAST(TIME_TO_STR(CreationDate, '%-HOUR') + 6.5 AS TEXT) + ' IST' AS time_of_the_day_ist, COUNT(1) AS no_of_posts FROM Posts WHERE OwnerUserId = @UserId GROUP BY TIME_TO_STR(CreationDate, '%-HOUR')
### Instruction: show me the flights from DENVER 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 = 'DENVER' 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: when do planes leave BOSTON for SAN FRANCISCO ### Response:
SELECT DISTINCT flight.departure_time FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: what the first height of patient 28443 during this month. ### Response:
SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 28443)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY chartevents.charttime LIMIT 1
### Instruction: show me all flights from PITTSBURGH 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 = 'PITTSBURGH' 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
### Instruction: what 's a flight that goes from BALTIMORE to SEATTLE ### 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 = 'SEATTLE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: First users to cast close votes on a closed post. Returns the user Id of the first user to cast a close vote on recently closed questions, ordered by closure timestamp. ### Response:
SELECT PostHistory.PostId AS "post_link", PostHistory.CreationDate AS PostClosureDate, PostHistory.UserId AS "user_link", PostHistory.Comment AS PostClosureComment, CAST(SUBSTRING(PostHistory.Text, STR_POSITION(PostHistory.Text, 'Voters') + 15, STR_POSITION(PostHistory.Text, 'Display') - STR_POSITION(PostHistory.Text, 'Voters') - 17) AS INT) AS "user_link", PostHistory.Text AS PostClosureText FROM PostHistory WHERE PostHistoryTypeId = 10 ORDER BY PostHistory.CreationDate DESC LIMIT 200
### Instruction: what is the percentile of 13.8 for a white blood cells test given the same age of patient 96833 on their current hospital encounter? ### Response:
SELECT DISTINCT t1.c1 FROM (SELECT labevents.valuenum, PERCENT_RANK() OVER (ORDER BY labevents.valuenum) AS c1 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'white blood cells') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age = (SELECT admissions.age FROM admissions WHERE admissions.subject_id = 96833 AND admissions.dischtime IS NULL))) AS t1 WHERE t1.valuenum = 13.8
### Instruction: is it patient 022-76925's respiration ever less than 23.0 on this month/06? ### Response:
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-76925')) AND vitalperiodic.respiration < 23.0 AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', vitalperiodic.observationtime) = '06'
### Instruction: has patient 17435 been given any k-phos 20mmol/500cc intake on the first intensive care unit visit? ### Response:
SELECT COUNT(*) > 0 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 = 17435) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'k-phos 20mmol/500cc' AND d_items.linksto = 'inputevents_cv')
### Instruction: what is patient 19412's average sao2 at since 12/23/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 = 19412)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sao2' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) >= '2105-12-23'
### Instruction: what were the drugs that were added to patient 8116 today, compared to those yesterday? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8116) AND DATETIME(prescriptions.startdate, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8116) AND DATETIME(prescriptions.startdate, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: If you compared EECS 453 and EECS 592 , which would you consider to be least difficult ? ### Response:
SELECT DISTINCT course.number FROM course INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (course.number = 453 OR course.number = 592) AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM program_course AS PROGRAM_COURSEalias1 INNER JOIN course AS COURSEalias1 ON PROGRAM_COURSEalias1.course_id = COURSEalias1.course_id WHERE (COURSEalias1.number = 453 OR COURSEalias1.number = 592) AND COURSEalias1.department = 'EECS')
### Instruction: please list the flight times from NEWARK to BOSTON ### Response:
SELECT DISTINCT flight.arrival_time, flight.departure_time FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'NEWARK' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: when patient 031-17834 got a microbiology test for the first time in 10/this year? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-17834')) AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', microlab.culturetakentime) = '10' ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: Does 351 meet in the Fall , if so when ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.start_time, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday FROM semester INNER JOIN course_offering ON semester.semester_id = course_offering.semester INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.department = 'EECS' AND course.number = 351 AND semester.semester = 'Fall' AND semester.year = 2016
### Instruction: show me the flights from SAN DIEGO 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 = 'SAN DIEGO' 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
### Instruction: i want to fly from BOSTON 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 = 'BOSTON' 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: please show all flights from PHILADELPHIA to DEN airport next sunday ### Response:
SELECT DISTINCT flight.flight_id FROM airport, airport_service, city, date_day, days, flight WHERE (airport.airport_code = 'DEN' 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.airport_code) AND city.city_code = airport_service.city_code AND city.city_name = 'PHILADELPHIA' AND flight.from_airport = airport_service.airport_code
### Instruction: Who taught Margie Ruiz in HISTORY 543 ? ### 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 = 'HISTORY' AND course.number = 543 AND student.firstname LIKE 'Margie' AND student.lastname LIKE 'Ruiz'
### Instruction: what's the output of patient 030-42006 for the first time on this month/27? ### Response:
SELECT intakeoutput.celllabel 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 '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '27' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: The times that International Security , Norms and Cooperation will be offered are what ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.start_time, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday FROM semester INNER JOIN course_offering ON semester.semester_id = course_offering.semester INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.name LIKE '%International Security , Norms and Cooperation%' AND semester.semester = 'FA' AND semester.year = 2016
### Instruction: top 10 users by post score. ### Response:
SELECT Users.Id AS "user_link", MAX(Age) AS Age, MAX(Location) AS Location, MAX(WebsiteUrl) AS Website, MAX(Reputation) AS Rep, COUNT(Answers.Id) AS Answers, SUM(Answers.Score) AS Score, CAST(AVG(CAST(Answers.Score AS FLOAT)) AS FLOAT(6, 1)) AS "avg" FROM Tags JOIN PostTags ON PostTags.TagId = Tags.Id JOIN Posts ON Posts.Id = PostTags.PostId JOIN Posts AS Answers ON Answers.ParentId = Posts.Id JOIN Users ON Users.Id = Answers.OwnerUserId GROUP BY Users.Id, DisplayName ORDER BY SUM(Answers.Score) DESC LIMIT 10
### Instruction: flight leaving 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, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'OAKLAND' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SALT LAKE CITY' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: interested in a flight from WASHINGTON to FORT WORTH ### 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 = 'WASHINGTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'FORT WORTH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: show me the flights from BALTIMORE to OAKLAND please ### 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 = 'OAKLAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: Avid answerers of the site, monthly history. ### Response:
WITH Raw AS (SELECT DATEFROMPARTS(TIME_TO_STR(CreationDate, '%Y'), TIME_TO_STR(CreationDate, '%M'), 1) AS Month, OwnerUserId AS UserId, CASE WHEN COUNT(*) > '##MaxCountPerMonth:int?5##' THEN '##MaxCountPerMonth##' ELSE COUNT(*) END AS AnswerCount FROM Posts WHERE PostTypeId = 2 AND OwnerUserId > 0 AND CreationDate < @TsNow GROUP BY DATEFROMPARTS(TIME_TO_STR(CreationDate, '%Y'), TIME_TO_STR(CreationDate, '%M'), 1), OwnerUserId) SELECT Month, AnswerCount, COUNT(*) AS UserCount FROM Raw GROUP BY Month, AnswerCount ORDER BY Month, AnswerCount
### Instruction: do you have one to DENVER from 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 = 'PHILADELPHIA' 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: Find Questions Migrated Without the User. Use this query to find where users have their post migrated but they never followed the question to the target site. ### Response:
SELECT OwnerDisplayName, Posts.Id AS "post_link", PostHistory.CreationDate AS "migration_date", Posts.CreationDate AS "original_post_date", SUBSTRING(PostHistory.Comment, 13, STR_POSITION(SUBSTRING(PostHistory.Comment, 13, LENGTH(PostHistory.Comment)), '.') - 1) AS "source_site" FROM Posts JOIN PostHistory ON Posts.Id = PostHistory.PostId WHERE PostHistory.PostHistoryTypeId = 36 AND Posts.PostTypeId = 1 AND OwnerUserId IS NULL ORDER BY 5, OwnerDisplayName, Posts.CreationDate DESC
### Instruction: i want to fly from DALLAS 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 = 'DALLAS' 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