instruction
stringlengths 53
549
| output
stringlengths 30
2.33k
|
---|---|
### Instruction:
was there an organism found in the last microbiological test of patient 031-9128's sputum, tracheal specimen until 2104?
### 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 = '031-9128')) AND microlab.culturesite = 'sputum, tracheal specimen' AND STRFTIME('%y', microlab.culturetakentime) <= '2104' ORDER BY microlab.culturetakentime DESC LIMIT 1 |
### Instruction:
when was patient 009-11964 last tested in 07/last year for alkaline phos.?
### 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 = '009-11964')) AND lab.labname = 'alkaline phos.' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', lab.labresulttime) = '07' ORDER BY lab.labresulttime DESC LIMIT 1 |
### Instruction:
PreMajor classes next Winter are being taught by who ?
### Response:
| SELECT DISTINCT instructor.name FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester INNER JOIN program_course ON program_course.course_id = course_offering.course_id INNER JOIN offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id WHERE program_course.category LIKE '%PreMajor%' AND semester.semester = 'Winter' AND semester.year = 2017 |
### Instruction:
Vanity: Which users earned a particular tag-based badge sooner than me?.
### Response:
| SELECT Users.DisplayName, Users.Id, DATEDIFF(day, Users.CreationDate, Date) AS Days FROM Badges INNER JOIN Users ON Users.Id = Badges.UserId WHERE Badges.Class = @BadgeType AND Badges.TagBased = 1 AND Badges.Name = @BadgeName AND DATEDIFF(day, Users.CreationDate, Date) <= (SELECT DATEDIFF(day, Users.CreationDate, Date) FROM Badges INNER JOIN Users ON Users.Id = Badges.UserId WHERE Badges.Class = @BadgeType AND Badges.TagBased = 1 AND Badges.Name = @BadgeName AND Badges.UserId = @UserId) ORDER BY Days |
### Instruction:
show flights between BOSTON and 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 = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code |
### Instruction:
there were any organism found in patient 93078's first sputum microbiology test in 06/last year?
### Response:
| SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 93078) AND microbiologyevents.spec_type_desc = 'sputum' AND NOT microbiologyevents.org_name IS NULL AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microbiologyevents.charttime) = '06' ORDER BY microbiologyevents.charttime LIMIT 1 |
### Instruction:
Of all the MATSCIE 400 classes which ones are in the morning .
### Response:
| SELECT DISTINCT course_offering.end_time, course_offering.start_time, semester.semester, semester.year FROM course, course_offering, semester WHERE course_offering.start_time < '12:00:00' AND course_offering.start_time >= '08:00:00' AND course.course_id = course_offering.course_id AND course.department = 'MATSCIE' AND course.number = 400 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
give me the CO flights from SEATTLE
### Response:
| SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SEATTLE' 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 flight.airline_code = 'CO' |
### Instruction:
Find Question with Specific Tag, Title and Answer Text.
### Response:
| SELECT P.Id AS "post_link", P.Tags FROM Posts AS P, PostTags AS Pt, Tags AS T WHERE P.Id = Pt.PostId AND T.Id = Pt.TagId AND T.TagName = '##tag1##' AND P.Title LIKE '%##titleText##%' AND P.PostTypeId = 1 AND P.AnswerCount > 0 AND NOT P.AcceptedAnswerId IS NULL AND NOT (SELECT P2.Id FROM Posts AS P2 WHERE P2.Id = P.AcceptedAnswerId AND P2.Body LIKE '%##answerText##%') IS NULL AND (SELECT COUNT(Pt.TagId) FROM PostTags AS Pt WHERE Pt.PostId = P.Id) = 1 |
### Instruction:
Are there multiple professors who teach ECON 631 in Spring-Summer 2003 ?
### Response:
| SELECT COUNT(DISTINCT instructor.instructor_id) FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'ECON' AND course.number = 631 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'Spring-Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2003 |
### Instruction:
when was the last time that patient 49036 received a procedure of sm bowel endoscopy nec until 2104?
### Response:
| SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'sm bowel endoscopy nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 49036) AND STRFTIME('%y', procedures_icd.charttime) <= '2104' ORDER BY procedures_icd.charttime DESC LIMIT 1 |
### Instruction:
what was the minimum daily number of patients who had malig neo bladder nec until 2 years ago?
### Response:
| SELECT MIN(t1.c1) FROM (SELECT COUNT(DISTINCT diagnoses_icd.hadm_id) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'malig neo bladder nec') AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY STRFTIME('%y-%m-%d', diagnoses_icd.charttime)) AS t1 |
### Instruction:
The easiest of all of the Core courses is taught by whom ?
### Response:
| SELECT DISTINCT instructor.name, program_course.workload 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 program_course ON program_course.course_id = course_offering.course_id WHERE program_course.category LIKE '%Core%' AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM program_course AS PROGRAM_COURSEalias1 WHERE PROGRAM_COURSEalias1.category LIKE '%Core%') |
### Instruction:
how many patients whose ethnicity is hispanic/latino - puerto rican and diagnoses long title is closed fracture of base of skull with subarachnoid, subdural, and extradural hemorrhage, with loss of consciousness of unspecified duration?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND diagnoses.long_title = "Closed fracture of base of skull with subarachnoid, subdural, and extradural hemorrhage, with loss of consciousness of unspecified duration" |
### Instruction:
how much did patient 19144 weigh last measured in their first hospital 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 = 19144 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 = 'admit wt' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1 |
### Instruction:
what is the drug that patient 006-71495 was prescribed two or more times until 46 months ago?
### Response:
| SELECT t1.drugname FROM (SELECT medication.drugname, COUNT(medication.drugstarttime) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-71495')) AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-46 month') GROUP BY medication.drugname) AS t1 WHERE t1.c1 >= 2 |
### Instruction:
when is the last sputum, tracheal specimen microbiological test on patient 025-44495 during the last hospital encounter?
### 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 = '025-44495' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND microlab.culturesite = 'sputum, tracheal specimen' ORDER BY microlab.culturetakentime DESC LIMIT 1 |
### Instruction:
Frequency of anonymous suggested edits. Returns the cumulative number of suggested edits that were submitted by anonymous users over the past NumberOfEdits suggested edits. If the anonymous suggestion rate was constant at x%, then the graph would show a straight line at slope 100x (e.g. if all edit suggestions were anonymous, a straight line with slope 1).
### Response:
| SELECT 'post_link', Score, NumEdits FROM (SELECT p.Id AS "post_link", p.Score AS Score, COUNT(ph.UserId) AS NumEdits FROM Posts AS p, PostHistory AS ph WHERE p.Id = ph.PostId AND p.Score >= 100 AND ph.UserId != p.OwnerUserId GROUP BY p.Id, p.Score) AS Y WHERE NumEdits >= 10 |
### Instruction:
what was the total amount of gastric tube production that patient 55281 had had during the previous day?
### Response:
| SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 55281)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'gastric tube' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') |
### Instruction:
when was patient 12572 since 4 years ago last diagnosed with ileostomy status?
### 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 = 'ileostomy status') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12572) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-4 year') ORDER BY diagnoses_icd.charttime DESC LIMIT 1 |
### Instruction:
In Summer of 2009 , how many professors taught CHEMBIO 502 ?
### Response:
| SELECT COUNT(DISTINCT instructor.instructor_id) FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'CHEMBIO' AND course.number = 502 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2009 |
### Instruction:
how many patients underwent a packed cell transfusion two 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 = 'packed cell transfusion') AND STRFTIME('%y', procedures_icd.charttime) >= '2104' GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 = 2 |
### Instruction:
tags distribution on the major legal tags non-legal related.
### Response:
| SELECT t.TagName, COUNT(*) AS "number_of_question" FROM PostTags AS pt INNER JOIN PostTags AS bpt ON pt.PostId = bpt.PostId INNER JOIN Tags AS bt ON bt.Id = bpt.TagId INNER JOIN Tags AS t ON t.Id = pt.TagId AND t.Id != bt.Id WHERE bt.TagName = '##tag##' AND t.TagName NOT IN ('licensing', 'gpl', 'open-source', 'lgpl', 'legal', 'mit-license', 'apache-license', 'commercial', 'gplv3', 'license-key', 'bsd-license') GROUP BY t.TagName ORDER BY COUNT(*) DESC LIMIT 100 |
### Instruction:
when patient 018-95228 was prescribed albumin 5% 500 ml inj last time since 141 months ago.
### 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 = '018-95228')) AND medication.drugname = 'albumin 5% 500 ml inj' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-141 month') ORDER BY medication.drugstarttime DESC LIMIT 1 |
### Instruction:
Dr. Kenneth Garner taught which classes ?
### Response:
| SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor WHERE course_offering.semester < (SELECT SEMESTERalias0.semester_id FROM semester AS SEMESTERalias0 WHERE SEMESTERalias0.semester = 'WN' AND SEMESTERalias0.year = 2016) AND course.course_id = course_offering.course_id AND instructor.name LIKE '%Kenneth Garner%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id |
### Instruction:
Questions bookmarked or commented on by user.
### Response:
| SELECT q.Id AS "post_link", q.CreationDate, q.Score, q.Tags, b.CreationDate AS "Bookmark date", c.CreationDate AS "Comment date", c.Id AS "comment_link" FROM Posts AS q LEFT OUTER JOIN Votes AS b ON q.Id = b.PostId AND b.VoteTypeId = 5 AND b.UserId = '##UserId:int##' LEFT JOIN LATERAL (SELECT Id, CreationDate FROM Comments WHERE PostId = q.Id AND UserId = '##UserId:int##' ORDER BY CreationDate LIMIT 1) AS c WHERE NOT b.Id IS NULL OR NOT c.Id IS NULL ORDER BY q.CreationDate DESC |
### Instruction:
how many hours was it since patient 006-14121's last sepsis - severe diagnosis during this hospital visit.
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnosis.diagnosistime)) FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-14121' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'sepsis - severe' ORDER BY diagnosis.diagnosistime DESC LIMIT 1 |
### Instruction:
how much is the minimum total hospital cost that includes prsnl hst oth nfct parst since 2105?
### Response:
| SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.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 = 'prsnl hst oth nfct parst')) AND STRFTIME('%y', cost.chargetime) >= '2105' GROUP BY cost.hadm_id) AS t1 |
### Instruction:
Which professor is running the ULCS classes next Winter ?
### Response:
| SELECT DISTINCT instructor.name FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester INNER JOIN program_course ON program_course.course_id = course_offering.course_id INNER JOIN offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id WHERE program_course.category LIKE '%ULCS%' AND semester.semester = 'Winter' AND semester.year = 2017 |
### Instruction:
count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
### Response:
| SELECT COUNT(*) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 32154)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'urine out foley' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m-%d', outputevents.charttime) >= '2101-11-19' |
### Instruction:
when was patient 15945 last having the maximum value of glucose in 12/this year?
### Response:
| SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15945) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'glucose') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', labevents.charttime) = '12' ORDER BY labevents.valuenum DESC, labevents.charttime DESC LIMIT 1 |
### Instruction:
what was the total tpn/ppn intake amount amount that patient 015-23047 had received since 578 days ago?
### 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 = '015-23047')) AND intakeoutput.celllabel = 'tpn/ppn intake amount' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-578 day') |
### Instruction:
calculate how many times patient 017-16041 had taken vascular 3 flush amount (ml) since 04/15/2103.
### 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-16041')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'vascular 3 flush amount (ml)' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2103-04-15' |
### Instruction:
give me the best restaurant in the bay area for american food ?
### Response:
| SELECT location.house_number, restaurant.name FROM geographic, location, restaurant WHERE geographic.region = 'bay area' AND restaurant.city_name = geographic.city_name AND restaurant.food_type = 'american' AND restaurant.id = location.restaurant_id AND restaurant.rating = (SELECT MAX(RESTAURANTalias1.rating) FROM geographic AS GEOGRAPHICalias1, restaurant AS RESTAURANTalias1 WHERE GEOGRAPHICalias1.region = 'bay area' AND RESTAURANTalias1.city_name = GEOGRAPHICalias1.city_name AND RESTAURANTalias1.food_type = 'american') |
### Instruction:
tell me the total amount of propofol that patient 022-78423 has taken since 11/29/2104?
### 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 = '022-78423')) AND intakeoutput.celllabel = 'propofol' AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2104-11-29' |
### Instruction:
how many hours have elapsed since the first time patient 021-79544 was diagnosed in the current hospital visit with pneumonia?
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnosis.diagnosistime)) FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-79544' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'pneumonia' ORDER BY diagnosis.diagnosistime LIMIT 1 |
### Instruction:
In next semester does Prof. Erkut Ozbay teach 445 ?
### Response:
| SELECT COUNT(*) > 0 FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 445 AND instructor.name LIKE '%Erkut Ozbay%' 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:
Comments asking the downvoter to explain.
### Response:
| SELECT Comments.Id AS "comment_link", Comments.UserId AS "user_link", Posts.ClosedDate AS Closed, Comments.CreationDate FROM Comments INNER JOIN Posts ON Comments.PostId = Posts.Id WHERE (LOWER(Text) LIKE '%@downvoter%' OR LOWER(Text) LIKE '%downvoter%' OR LOWER(Text) LIKE '%the downvote%' OR LOWER(Text) LIKE '%downvote%' OR LOWER(Text) LIKE '%down-voter%' OR LOWER(Text) LIKE '%@down-voter%') AND Comments.CreationDate > '2019-01-01' ORDER BY Comments.CreationDate DESC |
### Instruction:
since 1433 days ago, had patient 22782 had any l groin intake?
### Response:
| SELECT COUNT(*) > 0 FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22782)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'l groin' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) >= DATETIME(CURRENT_TIME(), '-1433 day') |
### Instruction:
How many time a week does the class meet for MUSTHTRE 141 ?
### Response:
| SELECT DISTINCT course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday 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 = 'MUSTHTRE' AND course.number = 141 AND semester.semester = 'WN' AND semester.year = 2016 |
### Instruction:
what were the top five most frequent diagnoses among the patients whose age was 40s?
### Response:
| SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 40 AND 49) GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5) |
### Instruction:
Top Answers for Negative Questions.
### Response:
| WITH q AS (SELECT * FROM dbo.Posts WHERE PostTypeId = 1) SELECT q.Id AS q_id, 'https://mi.yodeya.com/questions/' + CAST(q.Id AS TEXT(255)) AS q_url, q.Title AS q_title, q.Score AS q_score, A.Id AS a_id, 'https://mi.yodeya.com/a/' + CAST(a.Id AS TEXT(255)) AS a_url, a.Score AS a_score FROM q INNER JOIN dbo.Posts AS a ON a.ParentId = q.Id WHERE q.Score <= 0 ORDER BY (a.Score - q.Score) DESC LIMIT 100 |
### Instruction:
what is the number of times that patient 032-8005 had had a enteral/gastric tube intake #1 intake until 33 months ago?
### 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 = '032-8005')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'enteral/gastric tube intake #1' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-33 month') |
### Instruction:
Best of Code Review 2016 - Best Newcomer (question) category.
### Response:
| WITH FirstQuestions AS (SELECT MIN(p.Id) AS "postid" FROM Posts AS p WHERE p.PostTypeId = @Question GROUP BY p.OwnerUserId) SELECT fq.PostId AS "post_link", p.OwnerUserId AS "user_link", p.Score, p.CreationDate FROM FirstQuestions AS fq JOIN Posts AS p ON fq.PostId = p.Id WHERE TIME_TO_STR(CreationDate, '%YEAR') = @TargetYear AND p.ClosedDate IS NULL GROUP BY fq.PostId, p.OwnerUserId, p.Score, p.CreationDate ORDER BY p.Score DESC, p.CreationDate |
### Instruction:
when did patient 93571 get the int insert dual-cham dev procedure for the last time in 2103?
### Response:
| SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'int insert dual-cham dev') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 93571) AND STRFTIME('%y', procedures_icd.charttime) = '2103' ORDER BY procedures_icd.charttime DESC LIMIT 1 |
### Instruction:
how many days have passed since the last time patient 003-10080 on their current hospital encounter received a wbc x 1000 lab test?
### Response:
| SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '003-10080' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'wbc x 1000' ORDER BY lab.labresulttime DESC LIMIT 1 |
### Instruction:
Will I be able to take 502 on Mondays and Wednesdays ?
### Response:
| SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course_offering.friday = 'N' AND course_offering.monday = 'Y' AND course_offering.thursday = 'N' AND course_offering.tuesday = 'N' AND course_offering.wednesday = 'Y' AND course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 502 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
how many hours have passed since the first diagnosis of hypotension patient 006-47576 during the current hospital encounter?
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnosis.diagnosistime)) FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-47576' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'hypotension' ORDER BY diagnosis.diagnosistime LIMIT 1 |
### Instruction:
List of bounties offered in a given period.
### Response:
| SELECT p.Id AS "post_link", p.Score AS "Score", p.AnswerCount AS "Answers", bs.BountyAmount AS "Amount", CAST(TIME_TO_STR(bs.CreationDate, '%Y-%m-%d %H:%M:%S') AS TEXT(10)) AS "Bounty Start" FROM Posts AS p INNER JOIN Votes AS bs ON p.Id = bs.PostId AND bs.VoteTypeId = 8 AND bs.CreationDate >= '##Date1?2018-01-01##' AND bs.CreationDate <= '##Date2?2018-12-31##' ORDER BY bs.CreationDate DESC |
### Instruction:
when was the last time patient 006-80884 measured its respiration less than 15.0 since 8 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 = '006-80884')) AND vitalperiodic.respiration < 15.0 AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-8 day') ORDER BY vitalperiodic.observationtime DESC LIMIT 1 |
### Instruction:
Answers with 4 Delete Votes in the last Six Months.
### Response:
| SELECT V.PostId AS "post_link", P.OwnerUserId AS "user_link", P.Body FROM Votes AS V, Posts AS P, PostTypes AS Pt WHERE V.VoteTypeId = 10 AND DATEDIFF(month, V.CreationDate, GETDATE()) < 6 AND P.Id = V.PostId AND Pt.Id = P.PostTypeId AND Pt.Id = 2 AND (SELECT COUNT(V2.PostId) FROM Votes AS V2 WHERE V.VoteTypeId = 10 AND V2.PostId = P.Id) >= 4 GROUP BY V.PostId, P.OwnerUserId, P.Title, P.Body |
### Instruction:
Who is the instructor for Core Winter classes ?
### Response:
| SELECT DISTINCT instructor.name FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester INNER JOIN program_course ON program_course.course_id = course_offering.course_id INNER JOIN offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id WHERE program_course.category LIKE '%Core%' AND semester.semester = 'Winter' AND semester.year = 2017 |
### Instruction:
what was the total amount of blood loss that patient 022-82169 had on 10/23/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 = '022-82169')) AND intakeoutput.celllabel = 'blood loss' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2102-10-23' |
### Instruction:
In Winter 2004 , how many LAW 755 professors are there ?
### Response:
| SELECT COUNT(DISTINCT instructor.instructor_id) FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'LAW' AND course.number = 755 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'Winter' AND semester.semester_id = course_offering.semester AND semester.year = 2004 |
### Instruction:
total voting for a site.
### Response:
| SELECT SUM(UpVotes) AS TotUp, SUM(DownVotes) AS TotDown, SUM(UpVotes + DownVotes) AS TotVotes, SUM(UpVotes) * 1.0 / SUM(UpVotes + DownVotes) AS TotUpVotePercent, MIN(UpVotes * 1.0 / (UpVotes + DownVotes)) AS MinUpVotePercent, SUM(UpVotes + DownVotes) * 1.0 / SUM(DATEDIFF(Day, CreationDate, LastAccessDate)) AS AvgVotesPerDay FROM Users AS u WHERE UpVotes + DownVotes > '##Threshold##' AND DATEDIFF(Day, CreationDate, LastAccessDate) > 0 |
### Instruction:
how many hours have passed since patient 021-80293 received his last platelets x 1000 lab test during the current hospital encounter?
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '021-80293' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'platelets x 1000' ORDER BY lab.labresulttime DESC LIMIT 1 |
### Instruction:
what is the Dam or A[ ] Reservoir when the Borough or A[ ] Census area is valdez-cordova (ca), the gnis feature id# Link A[ ] B[ ] is less than 1417275 and the name A[ ] is sandra lake dam?
### Response:
| SELECT "Dam or A[\u203a ] Reservoir" FROM table_14297 WHERE "Borough or A[\u203a ] Census area" = 'valdez-cordova (ca)' AND "GNIS Feature ID # Link A[\u203a ] B[\u203a ]" < '1417275' AND "Name A[\u203a ]" = 'sandra lake dam' |
### Instruction:
Will all of Dr. Alex Halderman 's classes be available next semester and if not , which ones will be available ? ?
### 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 '%Alex Halderman%' 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:
what procedure is provided to patient 027-24468 two times until 40 months ago?
### Response:
| SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, COUNT(treatment.treatmenttime) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-24468')) AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-40 month') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 = 2 |
### Instruction:
Is 418 having 2 or 3 lectures a week ?
### Response:
| SELECT DISTINCT course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday, semester.semester, semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 418 AND semester.semester_id = course_offering.semester ORDER BY semester.semester_id DESC LIMIT 10 |
### Instruction:
Top Flutter Users in Vietnam.
### Response:
| WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", 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 '%vietnam%' AND TagName = 'flutter' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC |
### Instruction:
how many hours elapsed since the first time patient 010-16572 received a vancomycin - trough lab test in the current hospital encounter?
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '010-16572' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'vancomycin - trough' ORDER BY lab.labresulttime LIMIT 1 |
### Instruction:
until 02/2104, what was the monthly maximum value of the wbc x 1000 of patient 008-32147?
### Response:
| SELECT MAX(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 = '008-32147')) AND lab.labname = 'wbc x 1000' AND STRFTIME('%y-%m', lab.labresulttime) <= '2104-02' GROUP BY STRFTIME('%y-%m', lab.labresulttime) |
### Instruction:
since 2101, what was the average monthly number of patients diagnosed with cryptococcal meningitis?
### Response:
| SELECT AVG(t1.c1) FROM (SELECT COUNT(DISTINCT diagnoses_icd.hadm_id) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'cryptococcal meningitis') AND STRFTIME('%y', diagnoses_icd.charttime) >= '2101' GROUP BY STRFTIME('%y-%m', diagnoses_icd.charttime)) AS t1 |
### Instruction:
until 10/29/2103, when did patient 028-53285 receive an intake for the first time?
### 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 = '028-53285')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2103-10-29' ORDER BY intakeoutput.intakeoutputtime LIMIT 1 |
### Instruction:
In Spring-Summer 2000 , what courses does Prof. Lauren Sarringhaus teach ?
### 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 '%Lauren Sarringhaus%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'Spring-Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2000 |
### Instruction:
what is the average cost of hospital that involves a procedure called platelet transfusion during this year?
### Response:
| SELECT AVG(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 = 'platelet transfusion')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY cost.hadm_id) AS t1 |
### Instruction:
when did patient 96842 first have a diagnosis of pleural effusion nos during the last hospital visit?
### 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 = 'pleural effusion nos') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 96842 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY diagnoses_icd.charttime LIMIT 1 |
### Instruction:
How many different professors teach LHC 561 in Spring 2015 ?
### Response:
| SELECT COUNT(DISTINCT instructor.instructor_id) FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'LHC' AND course.number = 561 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 = 2015 |
### Instruction:
had patient 030-30152 been during this year diagnosed with rhabdomyolysis - with renal insufficiency?
### 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 = '030-30152')) AND diagnosis.diagnosisname = 'rhabdomyolysis - with renal insufficiency' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') |
### Instruction:
Can I have a list of the classes Dr. Avik Chakrabarti 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 '%Avik Chakrabarti%' 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:
when was the first time that in a year before patient 006-232560 was diagnosed with headache.
### 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 = '006-232560')) AND diagnosis.diagnosisname = 'headache' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY diagnosis.diagnosistime LIMIT 1 |
### Instruction:
what is the minimum hospital bill that includes retention urine nos the previous year?
### Response:
| SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.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 = 'retention urine nos')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.hadm_id) AS t1 |
### Instruction:
how many hours have passed since the last time in the current hospital visit patient 013-30085 has received bronchodilator treatment?
### 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 = '013-30085' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'bronchodilator' ORDER BY treatment.treatmenttime DESC LIMIT 1 |
### Instruction:
tell me the three most common diagnoses of patients aged 20s?
### Response:
| SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 20 AND 29) GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3) |
### Instruction:
What will Prof. Jordan Watkins be teaching in the Spring-Summer of 2016 ?
### 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 '%Jordan Watkins%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'Spring-Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
181 is being taught by Prof. Christopher Monk next semester ?
### Response:
| SELECT COUNT(*) > 0 FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 181 AND instructor.name LIKE '%Christopher Monk%' 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:
what is the maximum number of patients diagnosed with ami inferior wall, init daily until 4 years ago?
### Response:
| SELECT MAX(t1.c1) FROM (SELECT COUNT(DISTINCT diagnoses_icd.hadm_id) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'ami inferior wall, init') AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY STRFTIME('%y-%m-%d', diagnoses_icd.charttime)) AS t1 |
### Instruction:
what is the name of the diagnosis of patient 7073 last was received in the previous year?
### 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 = 7073) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY diagnoses_icd.charttime DESC LIMIT 1) |
### Instruction:
Bounty award // disconnect from acceptance // rep handling.
### Response:
| SELECT p.OwnerUserId, v.*, CASE VoteTypeId WHEN 1 THEN 15 END AS accepted, CASE VoteTypeId WHEN 8 THEN -BountyAmount WHEN 9 THEN BountyAmount END AS bounty, CASE VoteTypeId WHEN 2 THEN 10 WHEN 3 THEN -2 ELSE 0 END AS rep FROM Votes AS v INNER JOIN Posts AS p ON p.Id = v.PostId INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE v.VoteTypeId IN (1, 2, 3, 8, 9) AND p.CommunityOwnedDate IS NULL ORDER BY p.OwnerUserId, v.Id |
### Instruction:
when was the last time that on the current hospital visit patient 030-42006 was diagnosed with respiratory alkalosis - therapeutic hyperventilation.
### 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-42006' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'respiratory alkalosis - therapeutic hyperventilation' ORDER BY diagnosis.diagnosistime DESC LIMIT 1 |
### Instruction:
have any organisms been detected in patient 031-4987's last microbiological nasopharynx test since 3 years ago?
### 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 = '031-4987')) AND microlab.culturesite = 'nasopharynx' AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-3 year') ORDER BY microlab.culturetakentime DESC LIMIT 1 |
### Instruction:
how many hours has it been since the last time patient 012-31752 was given a bedside glucose test during the current hospital visit?
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '012-31752' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'bedside glucose' ORDER BY lab.labresulttime DESC LIMIT 1 |
### Instruction:
Who have been the past instructors for BIOMEDE 401 ?
### Response:
| SELECT DISTINCT instructor.name FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'BIOMEDE' AND course.number = 401 AND NOT (semester.semester = 'WN' AND semester.year = 2016) |
### Instruction:
since 907 days ago, when was the first time that patient 006-202432 had the maximum respiration?
### 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 = '006-202432')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-907 day') ORDER BY vitalperiodic.respiration DESC, vitalperiodic.observationtime LIMIT 1 |
### Instruction:
a month before has patient 016-18150 been getting any output amt-blake drain output?
### Response:
| SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-18150')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output amt-blake drain' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') |
### Instruction:
Is 520 available on Mondays and Wednesdays ?
### Response:
| SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course_offering.friday = 'N' AND course_offering.monday = 'Y' AND course_offering.thursday = 'N' AND course_offering.tuesday = 'N' AND course_offering.wednesday = 'Y' AND course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 520 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
select distinct * from posts p inner join posttags pt on pt.postid = p.id inner join tags t on pt.ta.
### Response:
| SELECT question.Id AS QuestionId, question.Score AS QuestionScore, question.Title AS QuestionTitle, question.Body AS QuestionBody, question.Tags, answer.Id AS AcceptedAnswerId, answer.Score AS AnswerScore, answer.Body AS AnswerBody FROM Posts AS question JOIN Posts AS answer ON question.AcceptedAnswerId = answer.Id INNER JOIN PostTags AS question_tags ON question_tags.PostId = question.Id INNER JOIN Tags ON question_tags.TagId = Tags.Id WHERE question.Id > '##LastFetchedQuestionId##' AND Tags.TagName IN ('##Tag##') ORDER BY question.Id LIMIT 100 |
### Instruction:
Which customers have used both the service named 'Close a policy' and the service named 'Upgrade a policy'? Give me the customer names.
### Response:
| SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "Close a policy" INTERSECT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "New policy application" |
### Instruction:
is the respiration in patient 021-246447 normal on 12/15/2104?
### 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 = '021-246447')) AND vitalperiodic.respiration BETWEEN respiration_lower AND respiration_upper AND NOT vitalperiodic.respiration IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) = '2104-12-15' |
### Instruction:
when did patient 032-4849 have an intake for the first time since 08/16/2104?
### 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 = '032-4849')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2104-08-16' ORDER BY intakeoutput.intakeoutputtime LIMIT 1 |
### Instruction:
Top Answerers for Tag: score = weighted sum of #accepted + #votes.
### Response:
| SELECT P.OwnerUserId AS "user_link", @AcceptWeight * SUM(CASE WHEN Q.AcceptedAnswerId = P.Id THEN 1 ELSE 0 END) + @ScoreWeight * SUM(P.Score) AS "TotalScore", 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 = Q.Id 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 LIMIT 20 |
### Instruction:
Posts with Scores above and beyond awarded Bounties.
### Response:
| SELECT P.Id AS "post_link", V.BountyAmount, (SELECT P2.Tags FROM Posts AS P2 WHERE P2.Id = P.ParentId) AS "tags", (SELECT P2.Score FROM Posts AS P2 WHERE P2.Id = P.ParentId) AS SCORES FROM Posts AS P, Votes AS V WHERE P.Id = V.PostId AND V.BountyAmount > 0 AND V.VoteTypeId = 9 AND (SELECT P2.Score FROM Posts AS P2 WHERE P2.Id = P.ParentId) > V.BountyAmount * 10 ORDER BY SCORES DESC, P.CreationDate DESC |
### Instruction:
what is the daily average of chesttube total output of patient 032-9230 on this hospital visit?
### 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 = '032-9230' AND patient.hospitaldischargetime IS NULL)) AND intakeoutput.celllabel = 'chesttube total' AND intakeoutput.cellpath LIKE '%output%' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) |
### Instruction:
in 05/last year was lasix prescribed to patient 021-32860?
### Response:
| SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-32860')) AND medication.drugname = 'lasix' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', medication.drugstarttime) = '05' |
### Instruction:
what is the total amount of dobutamine-in for patient 033-2671 until 580 days ago?
### 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 = '033-2671')) AND intakeoutput.celllabel = 'dobutamine-in' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-580 day') |
### Instruction:
If I want to take a class with Dr. Ryan Kellogg next semester , what are my choices ?
### 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 '%Ryan Kellogg%' 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:
what is the minimum total hospital cost, which includes thyrotox nos no crisis since 2 years ago?
### Response:
| SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.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 = 'thyrotox nos no crisis')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.hadm_id) AS t1 |
### Instruction:
Top scores for a given tag.
### Response:
| SELECT u.Id AS "user_link", SUM(CASE v.VoteTypeId WHEN 2 THEN 1 WHEN 3 THEN -1 END) AS Score, t.TagName FROM Users AS u INNER JOIN Posts AS a ON a.OwnerUserId = u.Id INNER JOIN Posts AS q ON q.Id = a.ParentId INNER JOIN PostTags AS pt ON pt.PostId = q.Id INNER JOIN Votes AS v ON v.PostId = a.Id INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE q.PostTypeId = 1 AND a.PostTypeId = 2 AND t.TagName = @tname GROUP BY u.Id, t.TagName ORDER BY Score DESC LIMIT 100 |
### Instruction:
when was the last time since 06/04/2103 patient 022-76925 heartrate was measured/taken?
### 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 = '022-76925')) AND NOT vitalperiodic.heartrate IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) >= '2103-06-04' ORDER BY vitalperiodic.observationtime DESC LIMIT 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.