instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: what are the five most commonly ordered tests in 2101 for patients aged 30s? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t1.itemid FROM (SELECT labevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND STRFTIME('%y', labevents.charttime) = '2101' GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 5)
### Instruction: had viral warts nos been diagnosed with patient 87733 until 2 years ago? ### Response:
SELECT COUNT(*) > 0 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'viral warts nos') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 87733) AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-2 year')
### Instruction: Are there courses in the Fall or Winter term at 300 -level ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course, course_offering, semester WHERE ((semester.semester = 'FA' AND semester.year = 2016) OR (semester.semester = 'WN' AND semester.year = 2017)) AND course.course_id = course_offering.course_id AND course.department = 'department0' AND course.number BETWEEN 300 AND 300 + 100 AND semester.semester_id = course_offering.semester
### Instruction: what is the dose of vitamin d, that patient 8324 was last prescribed in 08/last year? ### Response:
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8324) AND prescriptions.drug = 'vitamin d' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', prescriptions.startdate) = '08' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: Show the number of courses for each course description in a stacked bar chart The x-axis is course description and group by office name, and list in descending by the x-axis. ### Response:
SELECT CRS_DESCRIPTION, COUNT(CRS_DESCRIPTION) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM GROUP BY PROF_OFFICE, CRS_DESCRIPTION ORDER BY CRS_DESCRIPTION DESC
### Instruction: Which professor is teaching Interdisciplinary the Middle Ages this semester ? ### Response:
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_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 INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.name LIKE '%Interdisciplinary the Middle Ages%' AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: what was the last intake that patient 005-64055 had received since 614 days ago? ### 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-64055')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-614 day') ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: when was the first time patient 030-8973 had pneumonia - aspiration until 2104 diagnosed? ### Response:
SELECT diagnosis.diagnosistime FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-8973')) AND diagnosis.diagnosisname = 'pneumonia - aspiration' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2104' ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: patient 004-28929 has produced urine until 11/01/2103? ### 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 = '004-28929')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'urine' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2103-11-01'
### Instruction: count the number of times patient 010-6098 had been prescribed metoprolol tartrate 50 mg po tabs until 93 months ago? ### 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 = '010-6098')) AND medication.drugname = 'metoprolol tartrate 50 mg po tabs' AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-93 month')
### Instruction: Top Answerers for Tag: score = sum of answer scores/viewCount. ### Response:
SELECT P.OwnerUserId AS "user_link", SUM(1000 * P.Score / Q.ViewCount) AS TotalScore, SUM(P.Score) AS TotalVotes, SUM(Q.ViewCount) AS TotalViews, COUNT(*) AS "#Answers" FROM Posts AS P INNER JOIN Posts AS Q ON Q.Id = P.ParentId INNER JOIN PostTags AS PT ON PT.PostId = P.ParentId INNER JOIN Tags AS T ON T.Id = PT.TagId WHERE T.TagName = '##TagName##' AND NOT P.OwnerUserId IS NULL GROUP BY P.OwnerUserId ORDER BY TotalScore DESC
### Instruction: what the name was of the drug that patient 027-5581 was allergic to in 10/last year? ### Response:
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-5581')) AND DATETIME(allergy.allergytime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', allergy.allergytime) = '10'
### Instruction: when did patient 18866 last have a urine out foley event on the current icu visit? ### 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 = 18866) AND icustays.outtime IS NULL) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'urine out foley' AND d_items.linksto = 'outputevents') ORDER BY outputevents.charttime DESC LIMIT 1
### Instruction: Questions where tag display order will differ from inline editor / history.. ### Response:
WITH TagHistory AS (SELECT * FROM PostHistory WHERE PostHistoryTypeId IN (3, 6, 9)), MostRecentTagHistory AS (SELECT h1.PostId, h1.Text FROM TagHistory AS h1 LEFT JOIN TagHistory AS h2 ON (h1.PostId = h2.PostId AND h1.CreationDate < h2.CreationDate) WHERE h2.CreationDate IS NULL) SELECT p.Id, p.Tags AS "Tags in post", et.Text AS "Tags in revision" FROM Posts AS p INNER JOIN MostRecentTagHistory AS et ON p.Id = et.PostId WHERE p.Tags != et.Text
### Instruction: the number of patients who have been treated with drsl/drslumb fus ant/ant since 4 years ago. ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'drsl/drslumb fus ant/ant') AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-4 year'))
### Instruction: what is the first thing patient 4368 had for intake since 1798 days ago? ### 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 = 4368)) AND DATETIME(inputevents_cv.charttime) >= DATETIME(CURRENT_TIME(), '-1798 day') ORDER BY inputevents_cv.charttime LIMIT 1)
### Instruction: Next semester , what courses is Dr. Paul Bierdz teaching ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Paul Bierdz%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: list the patient ids of the patients that were diagnosed with rheum pulmon valve dis in this year. ### Response:
SELECT admissions.subject_id FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'rheum pulmon valve dis') AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
### Instruction: has patient 12568 excreted the foley since 260 days ago? ### 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 = 12568)) 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) >= DATETIME(CURRENT_TIME(), '-260 day')
### Instruction: What are the different grant amounts for documents sent before '1986-08-26 20:49:27' and after the grant ended on '1989-03-16 18:27:16'? ### Response:
SELECT T1.grant_amount FROM grants AS T1 JOIN documents AS T2 ON T1.grant_id = T2.grant_id WHERE T2.sent_date < '1986-08-26 20:49:27' INTERSECT SELECT grant_amount FROM grants WHERE grant_end_date > '1989-03-16 18:27:16'
### Instruction: Is Dr. Jennifer Hardacker teaching any classes next semester ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Jennifer Hardacker%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: fasting glucose of 100 _ 125 mg / dl ( impaired fasting glucose tolerance ) and / or 2 _ hour post _ load glucose of 140 _ 199 mg / dl ( impaired glucose tolerance ) ### Response:
SELECT * FROM table_train_180 WHERE fasting_glucose >= 100 AND fasting_glucose <= 125 OR impaired_glucose_tolerance = 1 OR (post_load_glucose >= 140 AND post_load_glucose <= 199) OR impaired_glucose_tolerance = 1
### Instruction: what were the top three diagnoses most frequently diagnosed since 6 years ago? ### Response:
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
### Instruction: Deletable questions with a tag. ### Response:
SELECT p.Id FROM Posts AS p WHERE (p.PostTypeId = 1 AND NOT p.ClosedDate IS NULL AND p.Score <= '##maxscore##' AND p.ViewCount <= '##maxviews##' AND p.Tags LIKE '%##tag##%' AND DATEDIFF(day, p.ClosedDate, GETDATE()) >= '##mindays##' AND '##maxscore##' >= ALL (SELECT a.Score FROM Posts AS a WHERE (a.ParentId = p.Id)) AND NOT EXISTS(SELECT pl.Id FROM PostLinks AS pl WHERE pl.PostId = p.Id AND pl.LinkTypeId = 3)) ORDER BY p.ClosedDate
### Instruction: what is the yearly maximum alanine aminotransferase (alt) value for patient 19987 until 2103? ### Response:
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19987) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'alanine aminotransferase (alt)') AND STRFTIME('%y', labevents.charttime) <= '2103' GROUP BY STRFTIME('%y', labevents.charttime)
### Instruction: the number of times that patient 027-154299 had received a analgesics - narcotic analgesic this year. ### Response:
SELECT COUNT(*) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-154299')) AND treatment.treatmentname = 'analgesics - narcotic analgesic' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: Do you know when 501 is offered ? ### Response:
SELECT DISTINCT semester.semester, semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 501 AND course_offering.semester = semester.semester_id AND semester.semester_id > (SELECT SEMESTERalias1.semester_id FROM semester AS SEMESTERalias1 WHERE SEMESTERalias1.semester = 'WN' AND SEMESTERalias1.year = 2016) ORDER BY semester.semester_id LIMIT 1
### Instruction: Copy Editor progress (including tags and about me). ### Response:
SELECT (SELECT COUNT(DISTINCT t.TagName) FROM Tags AS t JOIN Posts AS p ON p.Id = WikiPostId OR p.Id = ExcerptPostId WHERE p.LastEditorUserId = @UserId) + (SELECT COUNT(DISTINCT ph.PostId) FROM PostHistory AS ph JOIN Posts AS p ON p.Id = ph.PostId AND p.OwnerUserId != @UserId WHERE ph.UserId = @UserId AND ph.PostHistoryTypeId BETWEEN 4 AND 5) + (SELECT COUNT(DISTINCT u.AboutMe) FROM Users AS u WHERE u.Id = @UserId AND u.AboutMe != '')
### Instruction: Find questions contain tag 'polls'. SET @TargTags = LTRIM (RTRIM (@TargTags) ); ### Response:
SELECT Q.Id, Q.Tags, Q.Score, Q.Title, CAST(TIME_TO_STR(Q.CreationDate, '%Y%m%d') AS TEXT(10)) AS "date_asked", Q.AnswerCount AS "num_answers" FROM Posts AS Q WHERE Q.PostTypeId = 1 AND Q.ClosedDate IS NULL AND Q.Tags LIKE '%<Mass-Effect-3>%' AND LENGTH(Q.Body) > 5 AND Q.AnswerCount > 5 ORDER BY Q.AnswerCount DESC LIMIT 10
### Instruction: How many courses for each course description? Show me a stacked bar chart The x-axis is course description and group by office name, list by the X-axis from high to low. ### Response:
SELECT CRS_DESCRIPTION, COUNT(CRS_DESCRIPTION) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM GROUP BY PROF_OFFICE, CRS_DESCRIPTION ORDER BY CRS_DESCRIPTION DESC
### Instruction: Positive / 0 / Negative Scored Questions By Tag. Displays a count of positive, 0, and negatively scored questions by tag. Includes closed questions. ### Response:
SELECT SUM(CASE WHEN p.Score > 0 THEN 1 ELSE 0 END) AS Positive, SUM(CASE WHEN p.Score = 0 THEN 1 ELSE 0 END) AS Neutral, SUM(CASE WHEN p.Score < 0 THEN 1 ELSE 0 END) AS Negative, t.TagName FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE p.PostTypeId = 1 GROUP BY t.TagName ORDER BY COUNT(*) DESC
### Instruction: Which courses are Dr. Karen Acton teaching next semester ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Karen Acton%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: had patient 027-165214 in 02/this year been allergic to any substance? ### Response:
SELECT COUNT(*) > 0 FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-165214')) AND DATETIME(allergy.allergytime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', allergy.allergytime) = '02'
### Instruction: what was the last output that patient 23042 has had until 11/06/2104? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT outputevents.itemid 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 = 23042)) AND STRFTIME('%y-%m-%d', outputevents.charttime) <= '2104-11-06' ORDER BY outputevents.charttime DESC LIMIT 1)
### Instruction: what is the minimum hospital cost that includes a procedure known as hormonal therapy (for varices) since 3 years ago? ### Response:
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'hormonal therapy (for varices)')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: what was the last output that patient 26995 has had on 11/28/2104? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT outputevents.itemid 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 = 26995)) AND STRFTIME('%y-%m-%d', outputevents.charttime) = '2104-11-28' ORDER BY outputevents.charttime DESC LIMIT 1)
### Instruction: when was the heartrate of patient 028-52605 last measured until 1060 days ago? ### 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 = '028-52605')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-1060 day') ORDER BY vitalperiodic.observationtime DESC LIMIT 1
### Instruction: Does UKRAINE 252 only have sections before 10:00 , or are there any after ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '10:00' AND course.course_id = course_offering.course_id AND course.department = 'UKRAINE' AND course.number = 252 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: since 1 year ago what was diagnosed with patient 26398 for the first time? ### Response:
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT diagnoses_icd.icd9_code FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26398) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY diagnoses_icd.charttime LIMIT 1)
### Instruction: did patient 52604 receive renal sclerosis nos diagnosis until 2104? ### Response:
SELECT COUNT(*) > 0 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'renal sclerosis nos') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 52604) AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104'
### Instruction: count the number of times patient 016-38131 in their current hospital encounter has been prescribed with propofol 10 mg/1 ml 100ml sdv inj. ### 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-38131' AND patient.hospitaldischargetime IS NULL)) AND medication.drugname = 'propofol 10 mg/1 ml 100ml sdv inj'
### Instruction: did patient 022-3713 ever get an a respiration greater than 27.0 until 05/2105? ### 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-3713')) AND vitalperiodic.respiration > 27.0 AND NOT vitalperiodic.respiration IS NULL AND STRFTIME('%y-%m', vitalperiodic.observationtime) <= '2105-05'
### Instruction: Nr of discrete users posting questions about dotnetnuke per month. ### Response:
SELECT x.Yr, x.Qr, COUNT(x.Id) AS NrPosts FROM (SELECT p.Id, YEAR(p.CreationDate) AS Yr, TIME_TO_STR(p.CreationDate, '%q') AS Qr FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE p.CreationDate > '2015-01-01' AND t.TagName = 'dotnetnuke') AS x GROUP BY x.Yr, x.Qr ORDER BY x.Yr, x.Qr
### Instruction: Posts that had Bounties this Month. ### Response:
SELECT P.Id AS "post_link", V.BountyAmount, (SELECT P2.Tags FROM Posts AS P2 WHERE P2.Id = P.ParentId) AS "tags" FROM Posts AS P, Votes AS V WHERE P.Id = V.PostId AND NOT V.BountyAmount IS NULL AND V.VoteTypeId = 9 AND DATEDIFF(month, V.CreationDate, GETDATE()) < 1 AND (SELECT P2.Tags FROM Posts AS P2 WHERE P2.Id = P.ParentId) LIKE '<%##tag1##%>' ORDER BY V.BountyAmount DESC, P.CreationDate DESC
### Instruction: how many AA flights leave DENVER 6 10 ### Response:
SELECT COUNT(DISTINCT flight.flight_id) FROM airport_service, city, date_day, days, flight WHERE (city.city_code = airport_service.city_code AND city.city_name = 'DENVER' AND date_day.day_number = 10 AND date_day.month_number = 6 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.from_airport = airport_service.airport_code) AND flight.airline_code = 'AA'
### Instruction: when was the last time that patient 030-10559 has the minimum total co2 last month? ### Response:
SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-10559')) AND lab.labname = 'total co2' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY lab.labresult, lab.labresulttime DESC LIMIT 1
### Instruction: User with most questions asked. ### Response:
SELECT Users.Id AS "user_link", QuestionCounts.PostsCount AS "number_of_questions", AnswerCounts.PostsCount AS "number_of_answers" FROM (SELECT OwnerUserId, COUNT(Id) AS PostsCount FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId) AS QuestionCounts, (SELECT OwnerUserId, COUNT(Id) AS PostsCount FROM Posts WHERE PostTypeId = 2 GROUP BY OwnerUserId) AS AnswerCounts, Users WHERE Users.Id = QuestionCounts.OwnerUserId AND Users.Id = AnswerCounts.OwnerUserId ORDER BY QuestionCounts.PostsCount DESC LIMIT 50
### Instruction: what is the schedule of ground transportation from WASHINGTON airport into downtown ### Response:
SELECT DISTINCT ground_service.transport_type FROM airport, airport_service, city AS CITY_0, city AS CITY_1, ground_service WHERE airport.airport_code = airport_service.airport_code AND CITY_0.city_code = airport_service.city_code AND CITY_0.city_name = 'WASHINGTON' AND CITY_1.city_name = 'WASHINGTON' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_1.city_code
### Instruction: what was the last time that patient 17694 was diagnosed with 31-32 comp wks gestation? ### Response:
SELECT 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 = '31-32 comp wks gestation') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17694) ORDER BY diagnoses_icd.charttime DESC LIMIT 1
### Instruction: how much is the minimum total cost of a hospital that involves a drug called 20 ml vial : potassium chloride 2 meq/ml iv soln? ### Response:
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT medication.patientunitstayid FROM medication WHERE medication.drugname = '20 ml vial : potassium chloride 2 meq/ml iv soln')) GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: What sections does MEDEDUC 883 offer after 14:15 P.M. ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '14:15' AND course.course_id = course_offering.course_id AND course.department = 'MEDEDUC' AND course.number = 883 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: has patient 32168 received a procedure of packed cell transfusion until 3 years ago? ### Response:
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'packed cell transfusion') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 32168) AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-3 year')
### Instruction: could you tell me about ground transportation arrangements from the DFW airport to downtown DALLAS ### Response:
SELECT DISTINCT ground_service.transport_type FROM airport, airport_service, city AS CITY_0, city AS CITY_1, ground_service WHERE airport.airport_code = airport_service.airport_code AND CITY_0.city_name = 'DALLAS' AND CITY_1.city_code = airport_service.city_code AND CITY_1.city_name = 'DALLAS' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_0.city_code
### Instruction: Top 100 C++ Answerers in the last 100 days in location. ### Response:
SELECT u.Id AS "user_link", number_of_answers = COUNT(*), total_score = SUM(p.Score), u.Location FROM Users AS u JOIN Posts AS p ON p.OwnerUserId = u.Id JOIN Posts AS pp ON p.ParentId = pp.Id JOIN PostTags AS pt ON pt.PostId = pp.Id JOIN Tags AS t ON t.Id = pt.TagId WHERE t.TagName LIKE '%c++%' AND p.CreationDate > (CURRENT_TIMESTAMP() - 30) GROUP BY u.Id, u.Location ORDER BY 3 DESC LIMIT 100
### Instruction: Last year , who were the GSI 's for ASTRO 210 ? ### Response:
SELECT DISTINCT student.firstname, student.lastname FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN gsi ON gsi.course_offering_id = course_offering.offering_id INNER JOIN student ON student.student_id = gsi.student_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'ASTRO' AND course.number = 210 AND semester.semester = 'FA' AND semester.year = 2015
### Instruction: Which question words do posts start with?. ### Response:
WITH q_types AS (SELECT Id, CASE WHEN LOWER(Title) LIKE 'who %' THEN 'Who' WHEN LOWER(Title) LIKE 'what %' THEN 'What' WHEN LOWER(Title) LIKE 'when %' THEN 'When' WHEN LOWER(Title) LIKE 'where %' THEN 'Where' WHEN LOWER(Title) LIKE 'why %' THEN 'Why' WHEN LOWER(Title) LIKE 'how %' THEN 'How' ELSE 'Unknown' END AS q_type FROM Posts WHERE PostTypeId IN (SELECT Id FROM PostTypes WHERE Name = 'Question')) SELECT q_type, COUNT(Id) FROM q_types GROUP BY q_type
### Instruction: what is the last drug which was prescribed to patient 016-29746 via ivs route since 96 months ago? ### 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 = '016-29746')) AND medication.routeadmin = 'ivs' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-96 month') ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: TOP 500 users from Greece. Lists the top 500 users (ranked by reputation) that are located in Greece according to their profile information. A range of options is used to pinpoint members from Greece based on popular locations used. ### Response:
SELECT Id, DisplayName, Reputation, WebsiteUrl, Location FROM Users WHERE Location LIKE '%Thess%' OR Location LIKE '%Greece%' OR Location LIKE N'%Gr' OR Location LIKE N'%Patra%' OR (Location LIKE N'%Athens%' AND NOT Location LIKE N'%GA%' AND NOT Location LIKE N'%OH%' AND NOT Location LIKE N'%Ga%' AND NOT Location LIKE N'%Oh%') ORDER BY Reputation DESC LIMIT 500
### Instruction: Are 500 -level courses offered for the Fall or Winter terms ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course, course_offering, semester WHERE ((semester.semester = 'FA' AND semester.year = 2016) OR (semester.semester = 'WN' AND semester.year = 2017)) AND course.course_id = course_offering.course_id AND course.department = 'department0' AND course.number BETWEEN 500 AND 500 + 100 AND semester.semester_id = course_offering.semester
### Instruction: what is the total amount of input which patient 28447 has received on this month/29? ### 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 = 28447)) AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', inputevents_cv.charttime) = '29'
### Instruction: Random 500 Post with Accepted Answers. ### Response:
SELECT p.Id, p.Title, p.Body, p.Score FROM Posts AS p JOIN PostTags AS pt ON p.Id = pt.PostId JOIN Tags AS t ON pt.TagId = t.Id JOIN Posts AS a ON p.AcceptedAnswerId = a.Id WHERE (t.TagName = '##TagName:string##') AND (NOT p.AcceptedAnswerId IS NULL) AND (p.CreationDate >= '##Date1?2016-01-01##') AND (p.CreationDate <= '##Date2?2019-12-31##') ORDER BY RAND() LIMIT 500
### Instruction: Tell me the prerequisites for BIOMEDE 530 and 241 . ### 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_1.number = 530 OR COURSE_1.number = 241) AND COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'BIOMEDE'
### Instruction: Which Pop (2010) has an ANSI code smaller than 1036864, and a Longitude larger than -98.46611, and a Land (sqmi) smaller than 36.238, and a Latitude smaller than 48.144102? ### Response:
SELECT AVG("Pop. (2010)") FROM table_14022 WHERE "ANSI code" < '1036864' AND "Longitude" > '-98.46611' AND "Land ( sqmi )" < '36.238' AND "Latitude" < '48.144102'
### Instruction: what was the output of patient 035-24054 for the first time, since 826 days ago? ### 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 = '035-24054')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-826 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: what is the maximum hospital cost, which includes endosc remove bile stone since 2105? ### Response:
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'endosc remove bile stone')) AND STRFTIME('%y', cost.chargetime) >= '2105' GROUP BY cost.hadm_id) AS t1
### Instruction: Name the classes Dr. Stephen Pastner is teaching next semester . ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Stephen Pastner%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Best Algerian stack overflow users. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation, Age, Location, WebsiteUrl AS Wesbite, LastAccessDate AS Seen, CreationDate FROM Users WHERE Reputation >= '##MinimalReputation:int?1##' AND (UPPER(Location) LIKE UPPER('%Algeria%') OR UPPER(Location) LIKE UPPER('%Algerie%') OR UPPER(Location) LIKE UPPER('%Algiers%') OR UPPER(Location) LIKE UPPER('DZ') OR UPPER(Location) LIKE UPPER('% %')) ORDER BY Reputation DESC LIMIT 2000
### Instruction: tell me the number of times patient 004-13127 has got a voided amount today. ### 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 = '004-13127')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'voided amount' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
### Instruction: what is the top four prescription drugs among the patients with an age 50s in this year? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 50 AND 59) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 4
### Instruction: Give me a pie chart to show the proportion of each type of the thing that has the status 'Close' or has a status record before the date '2017-06-19 02:59:21'. ### Response:
SELECT Type_of_Thing_Code, COUNT(Type_of_Thing_Code) FROM Timed_Status_of_Things AS T1 JOIN Things AS T2 ON T1.thing_id = T2.thing_id WHERE T1.Status_of_Thing_Code = 'Close' OR T1.Date_and_Date < '2017-06-19 02:59:21' GROUP BY Type_of_Thing_Code
### Instruction: did there exist any microbiological tests for patient 031-17834's sputum, tracheal specimen when they came to the hospital last time? ### 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-17834' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND microlab.culturesite = 'sputum, tracheal specimen'
### Instruction: Bad questions with good answers. Highest score range between question and best answer, for questions with negative score that have answers with positive score. ### Response:
SELECT p.Id AS "post_link", p.Score, tmp.BestAnswerScore, tmp.BestAnswerScore - p.Score AS ScoreDiff, p.CreationDate, p.OwnerUserId AS "user_link" FROM Posts AS p INNER JOIN (SELECT ParentId, MAX(Score) AS BestAnswerScore FROM Posts WHERE PostTypeId = 2 GROUP BY ParentId) AS tmp ON p.Id = tmp.ParentId WHERE p.PostTypeId = 1 AND p.Score < 0 AND tmp.BestAnswerScore > 0 ORDER BY ScoreDiff DESC LIMIT 500
### Instruction: name the output that patient 29309 had for the first time on 01/06/2105? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT outputevents.itemid 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 = 29309)) AND STRFTIME('%y-%m-%d', outputevents.charttime) = '2105-01-06' ORDER BY outputevents.charttime LIMIT 1)
### Instruction: tell me when was the first time that patient 20603 measured arterial bp mean? ### Response:
SELECT chartevents.charttime FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20603)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime LIMIT 1
### Instruction: Locked posts without answers that haven't been migrated or merged. ### Response:
SELECT Id AS "post_link" FROM Posts WHERE AnswerCount = 0 AND Id IN (SELECT DISTINCT PostHistory.PostId AS "post_link" FROM PostHistory LEFT JOIN (SELECT DISTINCT PostId, CreationDate FROM PostHistory WHERE PostHistoryTypeId = 15) AS Unlocked ON PostHistory.PostId = Unlocked.PostId AND PostHistory.CreationDate < Unlocked.CreationDate WHERE PostHistory.PostHistoryTypeId = 14 AND Unlocked.PostId IS NULL) AND NOT EXISTS(SELECT * FROM PostHistory WHERE PostId = Posts.Id AND PostHistoryTypeId IN (35, 37))
### Instruction: when was the last time patient 027-22704 had the minimum respiration on the last icu visit. ### 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-22704') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.respiration IS NULL ORDER BY vitalperiodic.respiration, vitalperiodic.observationtime DESC LIMIT 1
### Instruction: has patient 025-5947 undergone any thyroid hormone - levothyroxine (t4) treatment since 5 years ago? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-5947')) AND treatment.treatmentname = 'thyroid hormone - levothyroxine (t4)' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-5 year')
### Instruction: HIghest voted VBA answers in the last 10 days (that aren't mine). ### Response:
SELECT DATEDIFF(d, a.CreationDate, GETDATE()) AS "answer_age_(days)", a.Id AS "post_link", q.Tags, a.Score AS aScore, q.Score AS qScore FROM Posts AS q LEFT OUTER JOIN Posts AS a ON q.Id = a.ParentId WHERE q.Tags LIKE '%vba>%' AND a.CreationDate >= DATEADD(d, -10, GETDATE()) AND NOT a.OwnerUserId LIKE '##UserID##' AND a.Score > 1 AND q.Score > 0 ORDER BY a.Score DESC, q.Score DESC
### Instruction: How many of the patients having cardiac catheterization as the cause of abnormal reaction of patient, or of later complication, without specifying misadventure at time of procedure, received additive therapy? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.long_title = "Cardiac catheterization as the cause of abnormal reaction of patient, or of later complication, without mention of misadventure at time of procedure" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: After 21:45 P.M. is there an ANTHRCUL 427 section ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '21:45' AND course.course_id = course_offering.course_id AND course.department = 'ANTHRCUL' AND course.number = 427 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: on 04/28/2100 what was the maximum value of sao2 of patient 010-19726? ### Response:
SELECT MAX(vitalperiodic.sao2) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-19726')) AND NOT vitalperiodic.sao2 IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) = '2100-04-28'
### Instruction: When is 628 available to take ? ### Response:
SELECT DISTINCT semester.semester, semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 628 AND course_offering.semester = semester.semester_id AND semester.semester_id > (SELECT SEMESTERalias1.semester_id FROM semester AS SEMESTERalias1 WHERE SEMESTERalias1.semester = 'WN' AND SEMESTERalias1.year = 2016) ORDER BY semester.semester_id LIMIT 1
### Instruction: Repeated questions + linked original question. ### Response:
SELECT orig.Id AS original_id, orig.Title AS original_title, rep.Id AS duplicate_Id, rep.Title AS duplicate_title FROM Posts AS orig INNER JOIN (SELECT Posts.Id, Posts.Title, Posts.Score, Posts.ViewCount, Posts.Body, PostLinks.RelatedPostId AS orig_Id FROM Posts INNER JOIN PostLinks ON Posts.Id = PostLinks.PostId WHERE Posts.PostTypeId = 1 AND NOT Posts.ClosedDate IS NULL AND PostLinks.LinkTypeId = 3) AS rep ON rep.orig_id = orig.Id WHERE orig.PostTypeId = 1
### Instruction: how many times patient 655 has had a d5w intake in their last hospital encounter? ### Response:
SELECT COUNT(*) 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 = 655 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd5w' AND d_items.linksto = 'inputevents_cv')
### Instruction: Users from Moscow with Q&A Posts with mscrm Tags. ### Response:
SELECT t.TagName FROM Posts AS p INNER JOIN Users AS u ON p.OwnerUserId = u.Id INNER JOIN PostTags AS pt ON pt.PostId = p.Id INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE LOWER(u.Location) LIKE @location UNION SELECT t.TagName FROM Posts AS p LEFT JOIN Posts AS q ON p.ParentId = q.Id INNER JOIN Users AS u ON p.OwnerUserId = u.Id INNER JOIN PostTags AS pt ON pt.PostId = q.Id INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE LOWER(u.Location) LIKE @location
### Instruction: what is the daily average value of vitamin b12 of patient 015-57922 until 2101? ### Response:
SELECT AVG(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-57922')) AND lab.labname = 'vitamin b12' AND STRFTIME('%y', lab.labresulttime) <= '2101' GROUP BY STRFTIME('%y-%m-%d', lab.labresulttime)
### Instruction: what was the total of patient 002-52932's input until 05/22/2100? ### 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 = '002-52932')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2100-05-22'
### Instruction: Is there a section of ECON 299 that is after 09:45 P.M. ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '09:45' AND course.course_id = course_offering.course_id AND course.department = 'ECON' AND course.number = 299 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Total Posts by Programming Languages Per Month - 2015. ### Response:
SELECT COUNT(*) AS PostCount, T.TagName, YEAR(P.CreationDate) FROM Posts AS P INNER JOIN PostTags AS PT ON (P.Id = PT.PostId) INNER JOIN Tags AS T ON (PT.TagId = T.Id) WHERE YEAR(P.CreationDate) > 2014 AND P.CreationDate < '2015-12-01' AND NOT TagName LIKE '%rails%' GROUP BY YEAR(P.CreationDate), T.TagName HAVING COUNT(PostId) > 800 ORDER BY 2 DESC, 3 DESC, 1 DESC
### Instruction: TOP VBA PERFORMERS for date range. Top VBA/Excel Users for specified date range (or enter 0 in both for 'last 10 days with data'). Ranked by Overall: Sum of ( comments + score + (Answers * 2) ) ### Response:
SELECT c.UserId, COUNT(c.Id) AS qComments FROM Comments AS c JOIN Posts AS q ON c.PostId = q.Id WHERE c.CreationDate >= DATEADD(d, -10, (SELECT MAX(CreationDate) FROM Posts)) AND (q.Tags LIKE '%vba>%' OR q.Tags LIKE '%excel%') GROUP BY c.UserId ORDER BY COUNT(c.Id) DESC
### Instruction: retrieve patient ids of patients who are diagnosed with abn react-urinary cath in this year. ### Response:
SELECT admissions.subject_id FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'abn react-urinary cath') AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
### Instruction: when was the last time that patient 002-1171 has the maximum temperature value on the first icu visit. ### 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 = '002-1171') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND NOT vitalperiodic.temperature IS NULL ORDER BY vitalperiodic.temperature DESC, vitalperiodic.observationtime DESC LIMIT 1
### Instruction: show the total amount of patient 011-29258's output until 08/17/2100. ### 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 = '011-29258')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2100-08-17'
### Instruction: Questions and answers in certain time period for specific tag. ### Response:
SELECT Q.Id AS "post_link" FROM Posts AS Q INNER JOIN PostTags ON PostTags.PostId = Q.Id INNER JOIN Tags ON Tags.Id = PostTags.TagId INNER JOIN Users ON Users.Id = Q.OwnerUserId WHERE NOT Tags.TagName LIKE @Pattern AND (@Closed = 1 OR Q.ClosedDate IS NULL) AND (Q.CreationDate BETWEEN @From AND @To OR EXISTS(SELECT * FROM Posts AS A WHERE A.ParentId = Q.Id AND A.CreationDate BETWEEN @From AND @To)) GROUP BY Q.Id, Q.CreationDate ORDER BY Q.CreationDate
### Instruction: in their last hospital visit has patient 012-26564 been diagnosed with tricyclic overdose - with respiratory depression? ### Response:
SELECT COUNT(*) > 0 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-26564' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND diagnosis.diagnosisname = 'tricyclic overdose - with respiratory depression'
### Instruction: what was the name of the specimen test patient 031-4423 received until 11/2104 for the last time? ### Response:
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4423')) AND STRFTIME('%y-%m', microlab.culturetakentime) <= '2104-11' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: count the number of times that patient 77177 in 2101 has received part sm bowel resect nec. ### Response:
SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'part sm bowel resect nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 77177) AND STRFTIME('%y', procedures_icd.charttime) = '2101'
### Instruction: since 2104, had patient 88409 received a opn transv colon res nec procedure? ### Response:
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'opn transv colon res nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 88409) AND STRFTIME('%y', procedures_icd.charttime) >= '2104'
### Instruction: calculate the total amount of input patient 002-39753 had until 09/29/2102. ### 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 = '002-39753')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2102-09-29'
### Instruction: Regarding the upper level electives for next Spring-Summer , which ones will be offered after 16:00 in the morning ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course_offering.start_time > '16:00' AND course.course_id = course_offering.course_id AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Spring-Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2017