instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: Group my answers by votes for a given tag. ### Response:
SELECT UpVotes, DownVotes, COUNT(*) AS AnswersCount FROM (SELECT UpVotes, DownVotes FROM (SELECT SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, SUM(CASE WHEN VoteTypeId = 3 THEN -1 ELSE 0 END) AS DownVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId LEFT JOIN Votes ON Votes.PostId = Posts.Id AND (VoteTypeId = 2 OR VoteTypeId = 3) WHERE Posts.OwnerUserId = @UserId AND Tags.TagName = @TagName GROUP BY Posts.Id) AS UpAndDownVotes) AS VotesCount GROUP BY UpVotes, DownVotes ORDER BY UpVotes DESC
### Instruction: Number of valuable PTIJ posts per year. ### Response:
SELECT TIME_TO_STR(p.CreationDate, '%y') AS year, p.Id, p.Score, p_a.AnswerCount FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id AND t.TagName = 'purim-torah-in-jest' INNER JOIN (SELECT ParentId, COUNT(p.Id) AS answercount FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id AND t.TagName = 'purim-torah-in-jest' WHERE p.PostTypeId = 2 GROUP BY p.ParentId) AS p_a ON p_a.ParentId = p.Id WHERE p.PostTypeId = 1
### Instruction: what was the maximum arterial bp [diastolic] during the previous day for patient 18866. ### 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 = 18866)) 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, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: Highest scoring questions and answers in each tag. ### Response:
SELECT TagName, QuestionID AS "post_link", q_.Score AS "q_score", AnswerID AS "post_link", a_.Score AS "a_score" FROM (SELECT TagName, (SELECT q.Id FROM Posts AS q INNER JOIN PostTags AS qt ON q.Id = qt.PostId WHERE qt.TagId = t.Id ORDER BY q.Score DESC LIMIT 1) AS QuestionID, (SELECT a.Id FROM Posts AS a INNER JOIN PostTags AS at ON a.ParentId = at.PostId WHERE at.TagId = t.Id ORDER BY a.Score DESC LIMIT 1) AS AnswerID FROM Tags AS t) AS temp INNER JOIN Posts AS q_ ON temp.QuestionId = q_.Id LEFT OUTER JOIN Posts AS a_ ON temp.AnswerId = a_.Id ORDER BY q_.Score DESC
### Instruction: i want to fly from DALLAS FORT WORTH 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 = 'DALLAS FORT WORTH' 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 days has it elapsed since patient 97395 was last diagnosed with ac/chr syst/dia hrt fail during this hospital encounter? ### 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 = 'ac/chr syst/dia hrt fail') 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: how many hours has it been since the first intake of fat emulsion 20% for patient 022-187132 on the current icu 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 = '022-187132') AND patient.unitdischargetime IS NULL) AND intakeoutput.celllabel = 'fat emulsion 20%' AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: Average wait time for question being answered based on hour of asking. ### Response:
SELECT TIME_TO_STR(QuestionWithT.CDate, '%-HOUR') AS AskingHour, AVG(QuestionWithT.T) AS AvgWaitTimeForFirstResponse FROM (SELECT Question.Id AS Id, MIN(Question.CreationDate) AS CDate, MIN(CAST((JULIANDAY(CreationDate) - JULIANDAY(Question.CreationDate)) * 1440.0 AS INT)) / (24.0 * 60) AS T FROM Posts AS Question, Posts AS Answer WHERE Answer.ParentId = Question.Id AND Question.PostTypeId = 1 AND Answer.PostTypeId = 2 GROUP BY Question.Id) AS QuestionWithT GROUP BY TIME_TO_STR(QuestionWithT.CDate, '%-HOUR')
### Instruction: tell me the percentile of mcv 97.0 in patients of the same age as patient 2127 during the last 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 = 'mcv') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age = (SELECT admissions.age FROM admissions WHERE admissions.subject_id = 2127 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1))) AS t1 WHERE t1.valuenum = 97.0
### Instruction: did patient 18866 have a respiratory rate that was greater than 12.0 in 12/2105? ### 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 = 18866)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'respiratory rate' AND d_items.linksto = 'chartevents') AND chartevents.valuenum > 12.0 AND STRFTIME('%y-%m', chartevents.charttime) = '2105-12'
### Instruction: does YX serve CLEVELAND ### 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 = 'CLEVELAND') OR (flight.from_airport = AIRPORT_SERVICE_1.airport_code AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CLEVELAND')) AND flight.airline_code = 'YX'
### Instruction: i was wondering what patient 15754's average value of temperature c (calc) on 09/05/2104 was? ### 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 = 15754)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'temperature c (calc)' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) = '2104-09-05'
### Instruction: what is patient 23969's first arterial bp [systolic] on the last intensive care unit visit? ### 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 = 23969) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime LIMIT 1
### Instruction: Median response time by tag (for any answer) - iOS- Initial Year. ### Response:
WITH my_table AS (SELECT T.TagName, CAST((JULIANDAY(CreationDate) - JULIANDAY(P.CreationDate)) * 1440.0 AS INT) AS ResponseMinutes FROM Posts AS P INNER JOIN Posts AS A ON P.AcceptedAnswerId = A.Id INNER JOIN PostTags AS PT ON P.Id = PT.PostId INNER JOIN Tags AS T ON T.Id = PT.TagId WHERE P.PostTypeId = 1 AND (T.TagName LIKE '%windows-phone%') AND p.AnswerCount > 0) SELECT DISTINCT TagName, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY ResponseMinutes) OVER (PARTITION BY TagName) AS Median FROM my_table
### Instruction: Top langs vs C, Python, JavaScript, Java & Rust average question score. ### Response:
SELECT CASE WHEN Tags LIKE '%<c>%' THEN 'C' WHEN Tags LIKE '%<python>%' THEN 'Python' WHEN Tags LIKE '%<javascript>%' THEN 'JavaScript' WHEN Tags LIKE '%<java>%' THEN 'Java' WHEN Tags LIKE '%<rust>%' THEN 'Rust' ELSE 'Anything else' END AS Language, AVG(CAST(Score AS FLOAT)) AS "average_score", COUNT(*) AS "n_questions" FROM Posts WHERE PostTypeId = 1 GROUP BY CASE WHEN Tags LIKE '%<c>%' THEN 'C' WHEN Tags LIKE '%<python>%' THEN 'Python' WHEN Tags LIKE '%<javascript>%' THEN 'JavaScript' WHEN Tags LIKE '%<java>%' THEN 'Java' WHEN Tags LIKE '%<rust>%' THEN 'Rust' ELSE 'Anything else' END
### Instruction: i mean what was the last temperature c (calc) for patient 4401 during the previous day? ### 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 = 4401)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'temperature c (calc)' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: when was the first time patient 029-23889 systemicdiastolic was measured greater than 63.0 on 07/03/2103. ### 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 = '029-23889')) AND vitalperiodic.systemicdiastolic > 63.0 AND NOT vitalperiodic.systemicdiastolic IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) = '2103-07-03' ORDER BY vitalperiodic.observationtime LIMIT 1
### 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 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: when did patient 013-17922 receive a prescription for insulin aspart in 05/last year first? ### 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 = '013-17922')) AND medication.drugname = 'insulin aspart' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', medication.drugstarttime) = '05' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: what were the total amount of d20w intake that patient 30171 had received on 05/30/2101? ### 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 = 30171)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd20w' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) = '2101-05-30'
### Instruction: what are the numbers of patients who have had a influenza vaccination two times during a year before? ### 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 = 'influenza vaccination') AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 = 2
### Instruction: Search for obsolete 'please accept' comments on my answers. Search your own comments for a string. Results show the comment, its score, the date, and a link to the post, newest comments first. ### Response:
SELECT Comments.Id AS "comment_link", Comments.CreationDate, Comments.PostId AS "post_link" FROM Comments, Posts AS Answer LEFT JOIN Posts AS Question ON Answer.ParentId = Question.Id WHERE Comments.PostId IN (Answer.Id, Question.Id) AND Answer.Id = Question.AcceptedAnswerId AND Answer.PostTypeId = 2 AND Answer.OwnerUserId = @MyUserID AND Comments.UserId = '##UserID##' AND Comments.Text LIKE '%/questions/5234/how-does-accepting-an-answer-work%' ORDER BY Comments.CreationDate DESC
### Instruction: show me the flights from SAN FRANCISCO to LAS VEGAS ### 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 = 'LAS VEGAS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: what was the total output of patient 016-9636's ileostomy on this month/29? ### 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 = '016-9636')) AND intakeoutput.celllabel = 'ileostomy' 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) = '29'
### Instruction: what was the last measured value of heartrate for patient 013-9305 on 06/12/last year? ### Response:
SELECT vitalperiodic.heartrate FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-9305')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', vitalperiodic.observationtime) = '06-12' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
### Instruction: Most prolific answering user for each tag. ### Response:
SELECT UserId, U.DisplayName, TagName, PostCount, RANK() OVER (PARTITION BY TagName ORDER BY PostCount DESC) AS PostCountRank FROM (SELECT COUNT(C.PostId) AS PostCount, C.UserId, C.UserDisplayName, T.TagName FROM Comments AS C INNER JOIN Posts AS P ON C.Id = P.AcceptedAnswerId INNER JOIN PostTags AS PT ON P.Id = PT.PostId INNER JOIN Tags AS T ON T.Id = PT.TagId WHERE T.TagName IN ('general-relativity', 'quantum-mechanics', 'electromagnetism') GROUP BY C.UserId, C.UserDisplayName, T.TagName) AS sub LEFT JOIN Users AS U ON UserId = U.Id ORDER BY PostCountRank LIMIT 70
### Instruction: i would like to fly to SAN FRANCISCO from 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 = 'WASHINGTON' 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 transportation time from the airport to BOSTON ### Response:
SELECT DISTINCT AIRPORT_SERVICE_0.minutes_distant FROM airport, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1 WHERE airport.airport_code = AIRPORT_SERVICE_0.airport_code AND airport.airport_code = AIRPORT_SERVICE_1.airport_code AND CITY_0.city_code = AIRPORT_SERVICE_1.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_0.city_code AND CITY_1.city_name = 'BOSTON'
### Instruction: was there any results of microbiology tests for the urine, catheter specimen of patient 031-1337 in 05/this year? ### Response:
SELECT COUNT(*) FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-1337')) AND microlab.culturesite = 'urine, catheter specimen' AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', microlab.culturetakentime) = '05'
### Instruction: did patient 8204 excreted any of his wound vac #1 in 06/this year? ### Response:
SELECT COUNT(*) > 0 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 = 8204)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'wound vac #1' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', outputevents.charttime) = '06'
### Instruction: had the respiratory rate of patient 2514 been greater until 172 months ago than 19.0? ### 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 = 2514)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'respiratory rate' AND d_items.linksto = 'chartevents') AND chartevents.valuenum > 19.0 AND DATETIME(chartevents.charttime) <= DATETIME(CURRENT_TIME(), '-172 month')
### Instruction: i would like to see the flights from DENVER 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 = 'DENVER' 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: tell me what was the top five most common procedures of the patients 60 or above 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 >= 60) AND STRFTIME('%y', procedures_icd.charttime) <= '2103' GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
### Instruction: when was the first time patient 25997 had a drug intake of carrier until 1062 days ago? ### 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 = 25997)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'carrier' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) <= DATETIME(CURRENT_TIME(), '-1062 day') ORDER BY inputevents_cv.charttime LIMIT 1
### Instruction: what was the last respiration of patient 030-64961 on 11/30/last year. ### Response:
SELECT vitalperiodic.respiration FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-64961')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', vitalperiodic.observationtime) = '11-30' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
### Instruction: Closed Questions with A Given Tag. ### Response:
SELECT DISTINCT p.Id FROM Posts AS p INNER JOIN PostHistory AS ph ON ph.PostId = p.Id INNER JOIN PostHistoryTypes AS pht ON ph.PostHistoryTypeId = pht.Id INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id AND (t.TagName LIKE 'c#' OR t.TagName LIKE 'asp.net%' OR t.TagName LIKE 'powershell' OR t.TagName LIKE 'sql-server%' OR t.TagName LIKE 'excel%' OR t.TagName LIKE 'csv%') WHERE NOT p.ClosedDate IS NULL AND pht.Name = 'Post Closed' AND ph.Comment = '102' AND p.CreationDate > '01 Jan 2016' ORDER BY p.Id DESC
### Instruction: how much did patient 8562 weigh last measured in the previous 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 = 8562)) 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, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: in 08/this year, when was the last time patient 028-62326 was prescribed a medication via the pr? ### 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 = '028-62326')) AND medication.routeadmin = 'pr' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '08' ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: character-id, object-id posts (Sci Fi SE). ### Response:
SELECT MIN(q.CreationDate) AS qda, MIN(q.Tags) AS qgl, 'site://q/' + CAST(q.Id AS TEXT) + '/' + CAST(MIN(m.Id) AS TEXT) + '|' + MIN(q.Title) AS qtl FROM Posts AS q LEFT JOIN (PostTags AS a JOIN Tags AS g ON a.TagId = g.Id) ON q.Id = a.PostId LEFT JOIN Users AS m ON m.AccountId = 1192385 WHERE q.PostTypeId = 1 AND g.TagName IN ('character-identification', 'object-identification', 'actor-identification', 'scene-identification') GROUP BY q.Id ORDER BY qda, q.Id
### Instruction: how many hours have elapsed since the first time patient 027-178044 received a anticoagulant administration - low molecular weight heparin treatment in this hospital visit? ### Response:
SELECT 24 * (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 = '027-178044' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'anticoagulant administration - low molecular weight heparin' ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: count the number of patients who had had a open incis hern-grft nec procedure done two or more times since 2104. ### 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 = 'open incis hern-grft nec') AND STRFTIME('%y', procedures_icd.charttime) >= '2104' GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 >= 2
### Instruction: tell me about flights from TORONTO 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 = 'TORONTO' 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: what is the new medicine prescribed for patient 99647 today compared to the drug yesterday? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 99647) 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 = 99647) AND DATETIME(prescriptions.startdate, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: TOP 100 Mejor promedio en respuestas. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY (SUM(P.Score) * 1.0) / COUNT(P.Id) DESC) AS "ranking", U.Id AS "user_link", SUM(P.Score) AS "puntaje_total_en_respuestas", COUNT(P.Id) AS "n mero_de_respuestas", ROUND((SUM(P.Score) * 1.0) / COUNT(P.Id), 4) AS "promedio" FROM Posts AS P INNER JOIN Users AS U ON P.OwnerUserId = U.Id WHERE PostTypeId = 2 GROUP BY U.Id HAVING COUNT(P.Id) >= 10 ORDER BY 'promedio' DESC LIMIT 100
### Instruction: during the first hospital encounter, what was the daily maximum dose of enteral 2 cal hn of patient 017-55081? ### Response:
SELECT MAX(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 = '017-55081' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND intakeoutput.celllabel = 'enteral 2 cal hn' AND intakeoutput.cellpath LIKE '%intake%' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
### Instruction: what was the name of the last intake that patient 016-18150 on last month/03 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 = '016-18150')) 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) = '03' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: what flights from SALT LAKE CITY to LAS VEGAS ### 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 = 'SALT LAKE CITY' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'LAS VEGAS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: SFMC related questions with answers. ### Response:
SELECT P.Id AS "post_link", P.PostTypeId, P.Title, P.Body, P.Tags, P.AnswerCount, P.CommentCount, C.Text, C.Score, C.Id, P.CreationDate, P.Score, P.ViewCount, P.OwnerUserId, P.LastEditDate, P.LastActivityDate FROM Posts AS P INNER JOIN Comments AS C ON P.Id = C.PostId WHERE P.PostTypeId = 1 AND (P.Tags LIKE '%##tag1##%' OR P.Tags LIKE '%##tag2##%' OR P.Tags LIKE '%##tag3##%' OR P.Tags LIKE '%##tag4##%' OR P.Tags LIKE '%##tag5##%' OR P.Tags LIKE '##tag6##') ORDER BY P.CreationDate DESC
### 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: 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: 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: 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: 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: 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