instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: when in 08/this year was patient 007-4322's first test for paco2? ### 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 = '007-4322')) AND lab.labname = 'paco2' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', lab.labresulttime) = '08' ORDER BY lab.labresulttime LIMIT 1
### Instruction: had d5ns ever been administered to patient 9297 since 04/2105? ### 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 = 9297)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd5ns' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m', inputevents_cv.charttime) >= '2105-04'
### 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: when was the last time that patient 028-55503 has been prescribed medication via intravenous route in a month before? ### Response:
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-55503')) AND medication.routeadmin = 'intravenous' AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: How many of the prerequisites for ASIANPAM 389 have I met ? ### Response:
SELECT COUNT(DISTINCT COURSE_1.department, COURSE_0.number) FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite, student_record WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'ASIANPAM' AND COURSE_1.number = 389 AND student_record.course_id = COURSE_0.course_id AND student_record.student_id = 1
### Instruction: v2 - Answers that are possibly link only which were posted by new users and question asker is new. credit to Bill the Lizard for help putting this together http://meta.stackexchange.com/a/238320/244519 ### Response:
SELECT p.Id AS "post_link", p.CreationDate, LEN(p.Body) AS BodyLength FROM Posts AS p INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE p.PostTypeId = 1 AND p.CreationDate > '2015-04-15T00:00:00.000' AND DATEDIFF(WEEK, u.CreationDate, CreationDate) < 104 ORDER BY p.CreationDate
### Instruction: count the number of times patient 95909 during this year had received thoracoscopic pleural bx. ### 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 = 'thoracoscopic pleural bx') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 95909) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: Since I need to leave by 5:00 P.M. each day to get to work on time , what time will 153 and 149 be over ? ### Response:
SELECT DISTINCT course_offering.end_time, course.number FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'department0' AND (course.number = 153 OR course.number = 149) AND course_offering.end_time < '17:00:00' AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: Users with edit privileges who have actually made edits.. ### Response:
WITH InstantEditors AS (SELECT u.* FROM PostHistory AS h INNER JOIN Posts AS p ON p.Id = h.PostId INNER JOIN Users AS u ON u.Id = h.UserId WHERE h.PostHistoryTypeId IN (4, 5, 6) AND h.RevisionGUID NOT IN (SELECT RevisionGUID FROM PostHistory WHERE PostHistoryTypeId = 24) AND h.UserId != p.OwnerUserId AND h.UserId > 0) SELECT (SELECT COUNT(DISTINCT Id) FROM InstantEditors) AS HaveMadeEdits, (SELECT COUNT(*) FROM Users WHERE Reputation >= 1000) AS CanMakeEdits, (SELECT COUNT(*) FROM Users) AS TotalUsers
### Instruction: Is it possible to take 560 on Wednesdays and Mondays ? ### 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 = 560 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: what was the organism detected during the first urine, catheter specimen microbiology test of patient 031-1337 on the first hospital encounter? ### Response:
SELECT microlab.organism FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-1337' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND microlab.culturesite = 'urine, catheter specimen' ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: what is the maximum number of monthly diagnosed cases of ch dvt/embl prox low ext since 2104? ### 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 = 'ch dvt/embl prox low ext') AND STRFTIME('%y', diagnoses_icd.charttime) >= '2104' GROUP BY STRFTIME('%y-%m', diagnoses_icd.charttime)) AS t1
### Instruction: when did patient 031-15417 first get the sputum, expectorated microbiology test in the last hospital visit? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-15417' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND microlab.culturesite = 'sputum, expectorated' ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: Am I able to take 452 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 = 452 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Popular tags over last 30 days. ### Response:
WITH tags_info AS (SELECT TagName, Votes.Id AS V_Id, Posts.Id AS P_Id, Posts.OwnerUserId AS P_OwnerUserId, Posts.CreationDate AS P_CreationDate FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId AND Posts.PostTypeId = 2 INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2) SELECT TagName FROM tags_info WHERE P_CreationDate >= DATEADD(DD, -30, GETDATE()) GROUP BY TagName HAVING COUNT(P_Id) >= 90 ORDER BY TagName
### Instruction: did patient 004-86136 have a non-invasive ventilation - nasal mask at other hospitals since 2104? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '004-86136' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '004-86136' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'non-invasive ventilation - nasal mask' AND STRFTIME('%y', treatment.treatmenttime) >= '2104'
### Instruction: what is the minimum total hospital cost to include a procedure called antiarrhythmics - class ii antiarrhythmic the last year? ### 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 = 'antiarrhythmics - class ii antiarrhythmic')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: Did Prof. Wayne High teach PATH 699 in Summer 2015 ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'PATH' AND course.number = 699 AND instructor.name LIKE '%Wayne High%' 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 = 2015
### Instruction: how many papers by michael i. jordan are cited by dan klein ### Response:
SELECT DISTINCT COUNT(cite.citingpaperid) FROM author AS AUTHOR_0, author AS AUTHOR_1, cite, writes AS WRITES_0, writes AS WRITES_1 WHERE AUTHOR_0.authorname = 'dan klein' AND AUTHOR_1.authorname = 'michael i. jordan' AND WRITES_0.authorid = AUTHOR_0.authorid AND WRITES_0.paperid = cite.citedpaperid AND WRITES_1.authorid = AUTHOR_1.authorid AND WRITES_1.paperid = cite.citingpaperid
### Instruction: what is the daily average amount of urine catheter that patient 012-20116 had during the current 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 = '012-20116' AND patient.hospitaldischargetime IS NULL)) AND intakeoutput.celllabel = 'urine catheter' AND intakeoutput.cellpath LIKE '%output%' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
### Instruction: User List: Top N - by Tag. ### Response:
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", DisplayName, Location, COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE TagName = '##tagName:string##' GROUP BY u.Id, DisplayName, Location) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
### Instruction: Top Answering HTML and CSS Question. ### 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 '%malaysia%' AND TagName = 'css' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
### Instruction: when was the first time that patient 015-12842 on the last icu visit had a heartrate that was less than 58.0? ### Response:
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-12842') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND vitalperiodic.heartrate < 58.0 AND NOT vitalperiodic.heartrate IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1
### Instruction: how many hours have it been since the first time that patient 006-202970 had received a bedside glucose lab test during their 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 = '006-202970' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'bedside glucose' ORDER BY lab.labresulttime LIMIT 1
### Instruction: Users who have posted more than 24 hours after first post. ### Response:
SELECT udfp.OwnerUserId AS "user_link", COUNT(p2.Id) AS futureposts FROM (SELECT p.OwnerUserId, MIN(p.CreationDate) AS dfp FROM Posts AS p WHERE p.PostTypeId < 3 GROUP BY p.OwnerUserId) AS udfp LEFT OUTER JOIN Posts AS p2 ON p2.OwnerUserId = udfp.OwnerUserId AND CAST((JULIANDAY(CreationDate) - JULIANDAY(udfp.dfp)) AS INT) >= 24 AND p2.PostTypeId < 3 GROUP BY udfp.OwnerUserId HAVING COUNT(p2.Id) > 0
### Instruction: at least 2 of the following: axillary temperature > 37.5 c or < 35.5 c or core temperature > 38 c or < 36 c; heart rate > 90 beats per minute; respiratory rate > 20 breaths per minute; or systolic blood pressure < 100 mmhg ### Response:
SELECT * FROM table_train_69 WHERE (CASE WHEN temperature > 37.5 OR temperature < 35.5 OR temperature > 38 OR temperature < 36 THEN 1 ELSE 0 END + CASE WHEN heart_rate > 90 THEN 1 ELSE 0 END + CASE WHEN systolic_blood_pressure_sbp < 100 THEN 1 ELSE 0 END) >= 2
### Instruction: until 08/2105, how many times was prescribed potassium phosphate 3 mmol/ml15 ml inj to patient 022-151182? ### 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 = '022-151182')) AND medication.drugname = 'potassium phosphate 3 mmol/ml15 ml inj' AND STRFTIME('%y-%m', medication.drugstarttime) <= '2105-08'
### Instruction: Is section for ENGR 561 available between 9:00 and 6:00 ? ### Response:
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.end_time <= '6:00' AND course_offering.start_time >= '9:00' AND course.course_id = course_offering.course_id AND course.department = 'ENGR' AND course.number = 561 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Top 100K users by hit rate (accepted answer percentage rate). 100 users having the highest accepted answer percentage rate (among users with >100 answers) ### Response:
SELECT u.Id AS "user_link", COUNT(a.Id), (CAST(SUM(CASE WHEN a.Id = q.AcceptedAnswerId THEN 1 ELSE 0 END) AS FLOAT) / COUNT(a.Id)) * 100 AS HitRate FROM Users AS u JOIN Posts AS a ON a.OwnerUserId = u.Id AND a.PostTypeId = 2 JOIN Posts AS q ON a.ParentId = q.Id GROUP BY u.Id HAVING COUNT(a.Id) > 25 ORDER BY HitRate DESC LIMIT 100000
### Instruction: what is the maximum hospital cost for a patient suffering from acute respiratory failure - due to atelectasis this year? ### Response:
SELECT MAX(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 diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'acute respiratory failure - due to atelectasis')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: what's the number of patients who had a ns/40gm ca glu intake until 4 years ago? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT icustays.hadm_id FROM icustays WHERE icustays.icustay_id IN (SELECT inputevents_cv.icustay_id FROM inputevents_cv WHERE inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'ns/40gm ca glu' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) <= DATETIME(CURRENT_TIME(), '-4 year')))
### Instruction: UWP top questions since May1, 2016 by viewcount. ### Response:
SELECT p.Id AS "post_link", Title, p.Tags AS Tags, p.ViewCount AS "Views", p.Score AS "Score", p.AnswerCount AS "Answers", DATEDIFF(day, p.CreationDate, GETDATE()) AS "Age (days)", p.AcceptedAnswerId AS "Answer Accepted?" FROM Posts AS p WHERE p.CreationDate >= '20160501' AND (p.Tags LIKE '%<uwp>%' OR p.Tags LIKE '%<windows-10-universal>%' OR (p.Tags LIKE '%<xaml>%' AND p.Tags LIKE '%<windows-10>%')) ORDER BY p.ViewCount DESC
### Instruction: Since I have to leave by 5:00 P.M. to get to work on time every day , what time will 416 and 336 be over ? ### Response:
SELECT DISTINCT course_offering.end_time, course.number FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'department0' AND (course.number = 416 OR course.number = 336) AND course_offering.end_time < '17:00:00' AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: Top C# users in the netherlands. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS "#", Posts.OwnerUserId AS "user_link", COUNT(*) AS UpVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2 INNER JOIN Users ON Posts.OwnerUserId = Users.Id WHERE Tags.Id = 9 AND (LOWER(Location) LIKE '%netherland%' OR LOWER(Location) LIKE '%nederland%' OR UPPER(Location) LIKE '%NL') GROUP BY TagName, Posts.OwnerUserId ORDER BY UpVotes DESC
### Instruction: provide the daily minimum amount of .45% normal saline that patient 15257 has received. ### Response:
SELECT MIN(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 = 15257)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '.45% normal saline' AND d_items.linksto = 'inputevents_cv') GROUP BY STRFTIME('%y-%m-%d', inputevents_cv.charttime)
### 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: tell me the total amount of ns that patient 003-17096 has taken since 11/07/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 = '003-17096')) AND intakeoutput.celllabel = 'ns' AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2104-11-07'
### Instruction: Who would be the teacher this Spring-Summer for FILMVID 302 ? ### 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 = 'FILMVID' AND course.number = 302 AND semester.semester = 'Spring-Summer' AND semester.year = 2016
### 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 much is the minimum hospital bill that includes mal neo lower 3rd esoph until 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 = 'mal neo lower 3rd esoph')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.hadm_id) AS t1
### 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: what was patient 021-113379's first prescribed time for chlorhexidine (periogard) 0.12 % oral rinse 15 ml? ### Response:
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-113379')) AND medication.drugname = 'chlorhexidine (periogard) 0.12 % oral rinse 15 ml' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: Who will be teaching Core 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 '%Core%' AND semester.semester = 'Winter' AND semester.year = 2017
### Instruction: Top User of Android Tag in India. ### 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 '%india%' AND TagName = 'android' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
### Instruction: when was patient 002-61035 diagnosed with primary lung cancer - adenocarcinoma until 2104 for the last time? ### 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 = '002-61035')) AND diagnosis.diagnosisname = 'primary lung cancer - adenocarcinoma' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2104' ORDER BY diagnosis.diagnosistime DESC LIMIT 1
### 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: has ever been greater than 64.0 the sao2 of patient 002-34744 until 05/12/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 = '002-34744')) AND vitalperiodic.sao2 > 64.0 AND NOT vitalperiodic.sao2 IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) <= '2104-05-12'
### Instruction: when has patient 594 received permanent ileostomy nec for the last time when they came to the hospital last time? ### 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 = 'permanent ileostomy nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 594 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY procedures_icd.charttime DESC LIMIT 1
### 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: when was the last time since 12/02/2103 the sao2 of patient 002-27133 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 = '002-27133')) AND NOT vitalperiodic.sao2 IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) >= '2103-12-02' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
### Instruction: I have fulfilled what prerequisites for REEES 695 already ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite, student_record WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'REEES' AND COURSE_1.number = 695 AND student_record.course_id = COURSE_0.course_id AND student_record.student_id = 1
### Instruction: what is the maximum daily number of patients with thrombot microangiopathy diagnosed until 2104? ### 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 = 'thrombot microangiopathy') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104' GROUP BY STRFTIME('%y-%m-%d', diagnoses_icd.charttime)) AS t1
### Instruction: Posts changed after I've changed them. ### Response:
SELECT 'site://posts/' + CAST(P.Id AS TEXT) + '/revisions|' + 'Revision History for Post ' + CAST(P.Id AS TEXT) AS "revision_link", P.Id AS "post_link", P.LastEditorUserId AS "user_link", P.LastEditDate FROM Posts AS P INNER JOIN PostHistory AS H ON H.PostId = P.Id WHERE P.OwnerUserId != @userid AND P.LastEditorUserId != @userid AND H.UserId = @userid AND H.CreationDate < P.LastEditDate GROUP BY P.Id, P.LastEditorUserId, P.LastEditDate ORDER BY P.LastEditDate DESC
### Instruction: hemoglobin < 10 g / dl for female , and < 11 g / dl for male , white blood cell count < 3000 / ul, platelet count of < 150000 / microliter, cd4+ count < 500 / microliter ### Response:
SELECT * FROM table_dev_17 WHERE (gender = 'female' AND hemoglobin_a1c_hba1c < 10) OR (gender = 'male' AND hemoglobin_a1c_hba1c < 11) AND white_blood_cell_count_wbc < 3000 AND platelet_count < 150000 AND cd4_count < 500
### Instruction: how many hours has it been since patient 002-34744's last lopressor prescription in this hospital encounter? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '002-34744') AND patient.hospitaldischargetime IS NULL) AND medication.drugname = 'lopressor' ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: patient 10431 has excreted any gu irrigant/urine volume out until 62 months 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 = 10431)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'gu irrigant/urine volume out' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime) <= DATETIME(CURRENT_TIME(), '-62 month')
### Instruction: First Posts Using Deprecated Tags. ### Response:
SELECT r.Id AS "ReviewID", p.Id AS "PostID", p.Title, p.CreationDate, p.Tags FROM Posts AS p LEFT JOIN ReviewTasks AS r ON p.Id = r.PostId LEFT JOIN ReviewTaskTypes AS rt ON r.ReviewTaskTypeId = rt.Id INNER JOIN PostTags AS pt ON p.Id = pt.PostId WHERE ReviewTaskStateId = 1 AND ReviewTaskTypeId = 4 AND pt.TagId IN (SELECT Tags.Id FROM Tags INNER JOIN Posts ON ExcerptPostId = Posts.Id WHERE (LOWER(Body) LIKE '%do not use%' OR LOWER(Body) LIKE '%deprecated%')) ORDER BY p.CreationDate
### Instruction: when did patient 031-9128 have a other microbiology test for the last time since 11/2104? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-9128')) AND microlab.culturesite = 'other' AND STRFTIME('%y-%m', microlab.culturetakentime) >= '2104-11' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: patient 027-136480 received the procedure of pulmonary resection - tumor in other hospitals since 2105? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '027-136480' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '027-136480' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'pulmonary resection - tumor' AND STRFTIME('%y', treatment.treatmenttime) >= '2105'
### Instruction: how many times did patient 31854 in 12/2105 receive br milk fs po? ### 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 = 31854)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'br milk fs po' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m', inputevents_cv.charttime) = '2105-12'
### Instruction: Each week 483 usually has 2 or 3 lectures ? ### 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 = 483 AND semester.semester_id = course_offering.semester ORDER BY semester.semester_id DESC LIMIT 10
### Instruction: how many days has it passed since the first time patient 027-120575 had a neurosurgery procedure during the current hospital encounter? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-120575' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'neurosurgery' ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: Top Swift users in UK. ### 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 '%costa rica%' AND TagName = 'ios' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
### Instruction: number of times patient 016-14220 has been prescribed nitroglycerin 0.4 mg(1/150) sl tab until 1 year 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 = '016-14220')) AND medication.drugname = 'nitroglycerin 0.4 mg(1/150) sl tab' AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-1 year')
### Instruction: has patient 86209 received diagnosis of esophageal reflux during this year? ### 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 = 'esophageal reflux') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 86209) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: Rep distribution - Distrubucion de la Reputacion. es == Generates a data table suitable for graphing Rep distribution, as a metric of site performance. Genera una dabka de datos apropiada para graficar la distribuci n de la reputaci n como m trica de desempe o de un sitio ### Response:
SELECT ROUND(Reputation / '##Width##', 0) * '##Width##' AS Rep, COUNT(*) AS number_of_users FROM (SELECT * FROM Users WHERE Reputation > 101) AS a GROUP BY ROUND(Reputation / '##Width##', 0) * '##Width##' ORDER BY ROUND(Reputation / '##Width##', 0) * '##Width##'
### Instruction: South African Users by Location. ### Response:
SELECT Location, COUNT(*) AS number FROM Users WHERE Location LIKE '%South Africa%' OR Location LIKE '%Cape Town%' OR Location LIKE '%Capetown%' OR Location LIKE '%Joburg%' OR Location LIKE '%Johannesburg%' OR Location LIKE '%JHB%' OR Location LIKE '%Gauteng%' OR Location LIKE '%Pretoria%' OR Location LIKE '%Western Cape%' OR Location LIKE '%Stellenbosch%' OR Location LIKE '%Durban%' OR Location LIKE '%KZN%' OR Location LIKE '%Port Elizabeth%' OR Location LIKE '%Midrand%' OR Location LIKE '%Sandton%' OR Location LIKE '%Randburg%' OR Location LIKE '%Limpopo%' OR Location LIKE '%Mpumalanga%' OR Location LIKE 'ZA' GROUP BY Location ORDER BY number DESC
### Instruction: What percentage of my answers are accepted?. Returns the total number of answers, the number of accepted answers, and what percentage of answers are accepted. ### Response:
SELECT COUNT(a.Id) AS "total_answers", SUM(CASE q.AcceptedAnswerId WHEN a.Id THEN 1 ELSE 0 END) AS "accepted_answers", ROUND(SUM(CASE q.AcceptedAnswerId WHEN a.Id THEN 1 ELSE 0 END) * 100.0 / COUNT(a.Id), 1) AS "percentage_accepted" FROM Posts AS a JOIN Posts AS q ON a.ParentId = q.Id WHERE a.OwnerUserId = 11742502 AND q.PostTypeId = 1 AND a.PostTypeId = 2
### Instruction: tell me patient 26772's average value of heart rate on the last icu visit? ### Response:
SELECT AVG(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26772) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents')
### Instruction: Can I take 513 on days like Monday and Wednesday ? ### 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 = 513 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: how many hours has it been since the last gastroenterology consultation of patient 033-22108 on their current hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '033-22108' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'gastroenterology consultation' ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: TOP 50 users from Vietnam. Lists the top 50 users (ranked by reputation) that are located in Calicut/Kozhikode, Kerala, India according to their profile information. Thanks to http://data.stackexchange.com/stackoverflow/qe/1157/top-100-users-from-greece ### Response:
SELECT Id, DisplayName, Age, Reputation, WebsiteUrl, Location, AboutMe, LastAccessDate, CreationDate FROM Users WHERE Location LIKE '%Vietnam%' OR Location LIKE '%HCM%' OR Location LIKE N'%Ho Chi Minh%' OR Location LIKE N'%Ha Noi%' OR Location LIKE N'%HaNoi%' OR Location LIKE N'%Viet Nam%' ORDER BY Reputation DESC LIMIT 150
### Instruction: did patient 027-136480 in 07/this year receive a peak airway/pressure lab test? ### Response:
SELECT COUNT(*) > 0 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-136480')) AND lab.labname = 'peak airway/pressure' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', lab.labresulttime) = '07'
### Instruction: how many days has it elapsed since patient 033-3992 was first diagnosed with sepsis in their current hospital visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnosis.diagnosistime)) FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '033-3992' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'sepsis' ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: Days I hit rep cap. Returns the days a user hit the rep cap ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY CreationDate) AS row, CreationDate, Votes FROM (SELECT SUM(CASE Votes.VoteTypeId WHEN 1 THEN 15 WHEN 2 THEN 10 WHEN 3 THEN -3 WHEN 9 THEN BountyAmount END) AS Votes, Votes.CreationDate AS CreationDate FROM Posts INNER JOIN Votes ON Votes.PostId = Posts.Id WHERE Posts.OwnerUserId = @UserId AND Posts.CommunityOwnedDate IS NULL AND Votes.CreationDate > '1/1/2011' GROUP BY Votes.CreationDate) AS t WHERE Votes >= 200
### 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: what was the maximum daily number of patients who were admitted for neonatal candida infect since 2101? ### 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 = 'neonatal candida infect') AND STRFTIME('%y', diagnoses_icd.charttime) >= '2101' GROUP BY STRFTIME('%y-%m-%d', diagnoses_icd.charttime)) 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: Top users for the Cassandra tag for the year. ### Response:
SELECT Users.DisplayName, COUNT(*) AS UpVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2 INNER JOIN Users ON Users.Id = Posts.OwnerUserId WHERE Tags.Id = 34113 AND Posts.CreationDate > '2015-01-01 00:00:00' AND Posts.CreationDate < '2016-01-01 00:00:00' GROUP BY Users.DisplayName ORDER BY UpVotes DESC
### Instruction: what's the minimum hospital cost if there is seizures - from ischemia/infarction last year? ### 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 diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'seizures - from ischemia/infarction')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
### 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 were the five most frequent diagnoses among the patients 30s? ### 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 30 AND 39) GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
### Instruction: how many hours has it passed since the first time patient 027-151154 received a laboratory -lymphs 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 = '027-151154' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = '-lymphs' ORDER BY lab.labresulttime LIMIT 1
### Instruction: when did patient 031-4987 first receive a nasopharynx microbiological test since 91 months ago? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4987')) AND microlab.culturesite = 'nasopharynx' AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-91 month') ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: what is the number of patients who have had a 1:1 ns repletion. intake since 1 year ago? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT icustays.hadm_id FROM icustays WHERE icustays.icustay_id IN (SELECT inputevents_cv.icustay_id FROM inputevents_cv WHERE inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '1:1 ns repletion.' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) >= DATETIME(CURRENT_TIME(), '-1 year')))
### Instruction: Top python users in Denver. ### 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 '%denver%' AND TagName = 'python' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
### Instruction: count the number of times patient 83901 had a stool out stool output in the last month. ### 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 = 83901)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'stool out stool' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
### Instruction: Can I register for 373 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 = 373 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016