instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### 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:
Top 100 stackoverflow user in Bangladesh.
### Response:
|
SELECT ROW_NUMBER() OVER (ORDER BY Users.Reputation DESC) AS "#", Users.Id AS "user_link", Users.Age, Users.Location, Users.Reputation, Users.Views, Users.UpVotes, Users.DownVotes, (SELECT COUNT(*) FROM Posts AS PQ WHERE PostTypeId = 1 AND PQ.OwnerUserId = Users.Id) AS "questions", (SELECT COUNT(*) FROM Posts AS PA WHERE PostTypeId = 2 AND PA.OwnerUserId = Users.Id) AS "answers" FROM Users WHERE UPPER(Users.Location) LIKE '%BANGLADESH%' OR UPPER(Users.Location) LIKE '%DHAKA%' ORDER BY Reputation DESC LIMIT 100
|
### 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:
what was the last height of patient 1912 on the last 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 = 1912 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
calculate how many times patient 12572 had received cont inv mec ven 96+ hrs during the previous year.
### 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 = 'cont inv mec ven 96+ hrs') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12572) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
Questions with a specific tag now and not at first revision.
### Response:
|
SELECT Posts.Id AS "post_link", Posts.Tags, PostInits.Text AS "initial_tags", Posts.CreationDate FROM Posts INNER JOIN (SELECT PostId, Text FROM PostHistory WHERE PostHistoryTypeId = 3 AND NOT Text LIKE '%##Tag##%') AS PostInits ON Posts.Id = PostInits.PostId WHERE Posts.Tags LIKE '%##Tag##%' AND (DATEDIFF(month, Posts.CreationDate, GETDATE()) <= '##MaxQuestionAgeInMonths:int?24##') AND (DATEDIFF(month, Posts.CreationDate, GETDATE()) >= '##MinQuestionAgeInMonths:int?0##') ORDER BY CreationDate DESC
|
### Instruction:
Top N answerers for a given tag from Denmark.
### Response:
|
SELECT TOP(100) AS TagName, SUM(CASE Votes.VoteTypeId WHEN 2 THEN 1 WHEN 3 THEN -1 END) AS Rep, Users.Id AS "user_link", number = ROW_NUMBER() OVER (ORDER BY TagName) FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Users ON Posts.OwnerUserId = Users.Id INNER JOIN Votes ON Votes.PostId = Posts.Id WHERE Tags.TagName = @tagName AND Posts.CommunityOwnedDate IS NULL AND (Location LIKE '%Copenhagen%') GROUP BY TagName, Users.Id ORDER BY Rep DESC
|
### Instruction:
what was patient 22973 last height in the last 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 = 22973 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
how many patients got tooth extraction nec two or more times until 2103?
### 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 = 'tooth extraction nec') AND STRFTIME('%y', procedures_icd.charttime) <= '2103' GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 >= 2
|
### Instruction:
what was the first time of patient 7073's intake on 09/09/last year?
### Response:
|
SELECT inputevents_cv.charttime FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7073)) AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', inputevents_cv.charttime) = '09-09' ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
The CLIMATE 105 in Spring 2012 is taught by what number of professors ?
### 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 = 'CLIMATE' AND course.number = 105 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 = 2012
|
### Instruction:
GEOG 201 will be taught by how many professors in 2001 Spring ?
### 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 = 'GEOG' AND course.number = 201 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 = 2001
|
### Instruction:
when was the first time that patient 004-28929 had the urine output since 1249 days ago?
### 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 = '004-28929')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'urine' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-1249 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
has patient 027-129174 been on ace inhibitor in any other hospitals in this year?
### Response:
|
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '027-129174' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '027-129174' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'ace inhibitor' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
what's the minimum total cost of the hospital that involves a procedure called anticoagulant administration - factor xa inhibitor during this 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 = 'anticoagulant administration - factor xa inhibitor')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
has patient 5310 taken a d10w drug in a month before?
### 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 = 5310)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd10w' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
|
### Instruction:
when was the last time patient 4684 received the procedure for a loc exc bone lesion nec in 2102?
### 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 = 'loc exc bone lesion nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 4684) AND STRFTIME('%y', procedures_icd.charttime) = '2102' ORDER BY procedures_icd.charttime DESC LIMIT 1
|
### Instruction:
What are the prerequisites that I have met for SOCADMIN 570 ?
### 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 = 'SOCADMIN' AND COURSE_1.number = 570 AND student_record.course_id = COURSE_0.course_id AND student_record.student_id = 1
|
### Instruction:
Who else has commented on the same posts?.
### Response:
|
SELECT u.Id AS "Other User ID", u.DisplayName AS "Name", u.Reputation AS "Reputation", co.CreationDate AS "Comment Date", p.Id AS "Answer ID", pp.Id AS "Question ID", pp.Title AS "Title" FROM Posts AS p JOIN Posts AS pp ON pp.Id = p.ParentId JOIN Comments AS c ON c.PostId = p.Id JOIN Comments AS co ON co.PostId = p.Id JOIN Users AS u ON co.UserId = u.Id WHERE p.PostTypeId = 2 AND c.UserId = 206691 AND co.UserId != 206691 AND p.OwnerUserId != 206691
|
### Instruction:
had patient 027-95744 had a topical antifungal procedure this year at other hospitals?
### Response:
|
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '027-95744' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '027-95744' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'topical antifungal' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
what was the three most commonly taken laboratory tests during a year before for patients of the age 50s?
### Response:
|
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t1.itemid FROM (SELECT labevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 50 AND 59) AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 3)
|
### Instruction:
Rep 'Created' vs Rep 'owned' by top X voters.
### Response:
|
WITH Voters AS (SELECT DISTINCT UpVotes, DownVotes, Id, Reputation FROM Users WHERE Reputation != 101 AND Reputation != 1) SELECT Users.Id AS "userlink", Users.DisplayName AS "sortname", Voters.UpVotes * 8 AS "estimatedaddedrep", Voters.DownVotes * 3 AS "estimateddestroyedrep", Users.Reputation AS "ownedrep" FROM Users, Voters WHERE Users.Id = Voters.Id GROUP BY Users.Id, Users.DisplayName, Users.Reputation, Voters.UpVotes, Voters.DownVotes ORDER BY EstimatedAddedRep DESC LIMIT 20
|
### Instruction:
when did patient 002-58884 in 11/this year receive the base excess test for the last time?
### 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 = '002-58884')) AND lab.labname = 'base excess' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', lab.labresulttime) = '11' ORDER BY lab.labresulttime DESC 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:
Is it possible for me to take 529 on Mondays 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 = 529 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
when was the last time patient 24517 received rt heart angiocardiogram's until 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 = 'rt heart angiocardiogram') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 24517) AND STRFTIME('%y', procedures_icd.charttime) <= '2103' ORDER BY procedures_icd.charttime DESC LIMIT 1
|
### 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:
Questions marked as duplicate without solved(WIP: Not Complete).
### Response:
|
/* SELECT * FROM POSTS PS WHERE PS.ID IN ( SELECT SUBSTRING(PH.Text,24,CHARINDEX(PH.Text, ']')) FROM Posts P INNER JOIN PostHistory PH ON P.Id=PH.PostId AND PH.PostHistoryTypeId =10 AND PH.Comment=1 WHERE P.ClosedDate IS NOT NULL ) */ SELECT SUBSTRING(PH.Text, STR_POSITION(ph.Text, ''), STR_POSITION(PH.Text, '')) FROM Posts AS P INNER JOIN PostHistory AS PH ON P.Id = PH.PostId AND PH.PostHistoryTypeId = 10 AND PH.Comment = 1 WHERE NOT P.ClosedDate IS NULL
|
### Instruction:
when was the last time patient 013-28507 sao2 was measured greater than 91.0 on the first intensive care unit visit.
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-28507') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND vitalperiodic.sao2 > 91.0 AND NOT vitalperiodic.sao2 IS NULL ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
what's the name of the drug that patient 49036's been prescribed two times in 09/last year?
### Response:
|
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 49036) AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', prescriptions.startdate) = '09' GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
|
### Instruction:
when patient 9297 received manual reduction hernia first in this year?
### 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 = 'manual reduction hernia') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9297) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY procedures_icd.charttime LIMIT 1
|
### Instruction:
has patient 007-2498 received a procedure of nephrostomy - right in other hospitals in this year?
### Response:
|
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '007-2498' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '007-2498' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'nephrostomy - right' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
Are there usually 2 or 3 lectures held for 541 per 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 = 541 AND semester.semester_id = course_offering.semester ORDER BY semester.semester_id DESC LIMIT 10
|
### Instruction:
what is the average total cost of hospitals that include late eff accidental fall in this year?
### Response:
|
SELECT AVG(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 = 'late eff accidental fall')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY cost.hadm_id) AS t1
|
### Instruction:
Recent Java questions from higher-rep users.
### Response:
|
SELECT DISTINCT A.Id, A.CreationDate, C.Reputation, A.Score, A.AcceptedAnswerId, A.Title, A.Body FROM Posts AS A INNER JOIN PostTypes AS B ON A.PostTypeId = B.Id INNER JOIN Users AS C ON A.OwnerUserId = C.Id INNER JOIN PostTags AS D ON A.Id = D.PostId INNER JOIN Tags AS E ON D.TagId = E.Id WHERE A.CreationDate > DATEADD(week, DATEDIFF(week, 0, GETDATE()) - 1, -1) AND B.Name = 'Question' AND C.Reputation > 100 AND E.TagName = 'javascript' ORDER BY A.CreationDate DESC
|
### Instruction:
in the last bronchial lavage microbiology test of patient 031-19622 until 3 years ago was there any organism found?
### 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-19622')) AND microlab.culturesite = 'bronchial lavage' AND DATETIME(microlab.culturetakentime) <= DATETIME(CURRENT_TIME(), '-3 year') ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
when was the first time of the prescription for patient 011-14590 in 03/this year?
### 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 = '011-14590')) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '03' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
how many hours has time elapsed since patient 013-28507's last stress ulcer prophylaxis in this hospital visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-28507' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'stress ulcer prophylaxis' ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
Usually every week , are there 2 or 3 lectures for 417 ?
### 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 = 417 AND semester.semester_id = course_offering.semester ORDER BY semester.semester_id DESC LIMIT 10
|
### Instruction:
Which is easier , 282 or 460 ?
### Response:
|
SELECT DISTINCT course.number FROM course INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (course.number = 282 OR course.number = 460) AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM program_course AS PROGRAM_COURSEalias1 INNER JOIN course AS COURSEalias1 ON PROGRAM_COURSEalias1.course_id = COURSEalias1.course_id WHERE (COURSEalias1.number = 282 OR COURSEalias1.number = 460) AND COURSEalias1.department = 'EECS')
|
### Instruction:
last year patient 007-10135 had been prescribed glucagon (human recombinant) 1 mg/ml solution for injection?
### 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 = '007-10135')) AND medication.drugname = 'glucagon (human recombinant) 1 mg/ml solution for injection' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
when was the last time patient 006-83902 had a chest tube #2 output on the last icu visit?
### 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 = '006-83902') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'chest tube #2' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
has patient 012-63986 been prescribed sublimaze, dextrose 50%, or lorazepam in this month?
### 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 = '012-63986')) AND medication.drugname IN ('sublimaze', 'dextrose 50%', 'lorazepam') AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
|
### Instruction:
what would be the maximum daily number of patients diagnosed with fall from chair in this year?
### 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 = 'fall from chair') AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY STRFTIME('%y-%m-%d', diagnoses_icd.charttime)) AS t1
|
### Instruction:
What 's the number of professors teaching SEAS 502 in Summer 2005 ?
### 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 = 'SEAS' 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 = 2005
|
### Instruction:
when did patient 032-13376 first got the minimum of sao2 until 04/12/2104?
### 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 = '032-13376')) AND NOT vitalperiodic.sao2 IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) <= '2104-04-12' ORDER BY vitalperiodic.sao2, vitalperiodic.observationtime LIMIT 1
|
### Instruction:
Top 20 reputation whores in PHP tag.
### Response:
|
SELECT Users.Id AS Id, Users.DisplayName AS Nickname, COUNT(Answers.Score) * 10 AS Reputation FROM Posts AS Answers INNER JOIN Posts AS Questions ON Questions.Id = Answers.ParentId INNER JOIN Users AS Users ON Answers.OwnerUserId = Users.Id INNER JOIN PostTags ON PostTags.PostId = Answers.ParentId INNER JOIN Tags ON Tags.Id = PostTags.TagId WHERE Answers.PostTypeId = 2 AND NOT Answers.OwnerUserId IS NULL AND Tags.TagName = 'c++' AND (Questions.ClosedDate != '' OR Questions.Score < 0) GROUP BY Users.Id, Users.DisplayName ORDER BY Reputation DESC LIMIT 20
|
### Instruction:
Is it possible for me to take 311 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 = 311 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
What number of professors will be teaching FRENCH 378 in Spring 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 = 'FRENCH' AND course.number = 378 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 = 2003
|
### Instruction:
All tables with column information.. Simple but useful. Returns all tables in ASC order, along with all their columns in order, their data type name, character limit and whether it is nullable.
### Response:
|
SELECT sys.tables.name AS "table_name", sys.columns.name AS "column_name", sys.columns.column_id AS "column_id", sys.types.name AS "data_type", sys.columns.max_length AS "max_length", sys.columns.is_nullable AS "nullable?" FROM sys.columns INNER JOIN sys.tables ON sys.columns.object_id = sys.tables.object_id INNER JOIN sys.types ON sys.types.user_type_id = sys.columns.user_type_id ORDER BY sys.tables.name, sys.columns.column_id
|
### Instruction:
Usually , are there 2 or 3 lectures for 312 every 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 = 312 AND semester.semester_id = course_offering.semester ORDER BY semester.semester_id DESC LIMIT 10
|
### Instruction:
when did patient 031-15417 last take his or her sputum, expectorated microbiology test during their first 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 = '031-15417' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND microlab.culturesite = 'sputum, expectorated' ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
did kcl 10%, potassium chloride, or ephedrine sulfate be prescribed to patient 003-54468 in 2105?
### 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 = '003-54468')) AND medication.drugname IN ('kcl 10%', 'potassium chloride', 'ephedrine sulfate') AND STRFTIME('%y', medication.drugstarttime) = '2105'
|
### Instruction:
Top users with number/score from answers and from questions.
### Response:
|
SELECT u.Id AS "user_link", u.Reputation, SUM(CASE WHEN p.PostTypeId = 1 THEN 1 ELSE 0 END) AS "total_questions", SUM(CASE WHEN p.PostTypeId = 2 THEN 1 ELSE 0 END) AS "total_answers", SUM(CASE WHEN p.PostTypeId = 1 THEN p.Score ELSE 0 END) AS "score_questions", SUM(CASE WHEN p.PostTypeId = 1 THEN p.Score ELSE 0 END) AS "score_answers" FROM Users AS u INNER JOIN Posts AS p ON p.OwnerUserId = u.Id GROUP BY u.Id, u.Reputation ORDER BY u.Reputation DESC LIMIT 500
|
### Instruction:
when was first time that patient 021-240586 had the minimum heartrate until 05/19/2102?
### 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 = '021-240586')) AND NOT vitalperiodic.heartrate IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) <= '2102-05-19' ORDER BY vitalperiodic.heartrate, vitalperiodic.observationtime LIMIT 1
|
### Instruction:
has patient 15794 excreted the drain out #3 jackson pratt since 12/2105?
### 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 = 15794)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'drain out #3 jackson pratt' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m', outputevents.charttime) >= '2105-12'
|
### 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:
what was the first height of patient 3242 on their first hospital encounter.
### 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 = 3242 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 ht' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
when was the first time patient 025-10988's heartrate was greater than 97.0 since 4 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 = '025-10988')) AND vitalperiodic.heartrate > 97.0 AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-4 day') ORDER BY vitalperiodic.observationtime 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:
what was the name of the drug prescribed during the last hospital encounter to patient 002-56853 two times?
### 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 = '002-56853' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) GROUP BY medication.drugname) AS t1 WHERE t1.c1 = 2
|
### 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:
Percentage of first posts which get closed (per day, between dates).
### Response:
|
WITH firstpostids_cte AS (SELECT MIN(Id) AS MinId, OwnerUserId FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId), firstpostsclosed_cte AS (SELECT p.Id, p.CreationDate AS cre, p.ClosedDate AS clo FROM firstpostids_cte AS fp JOIN Posts AS p ON fp.MinId = p.Id) SELECT DATE(cre), ROUND((COUNT(clo)) * 100.0 / (COUNT(*)), 2) AS percentage FROM firstpostsclosed_cte WHERE cre >= '##Date1##' AND cre <= '##Date2##' GROUP BY DATE(cre) ORDER BY DATE(cre)
|
### Instruction:
when was the first time that patient 5544 had maximum phosphate value in 04/this year?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 5544) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'phosphate') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', labevents.charttime) = '04' ORDER BY labevents.valuenum DESC, labevents.charttime LIMIT 1
|
### Instruction:
what is the maximum amount of total hospital cost including abn react-anastom/graft since 1 year ago?
### Response:
|
SELECT MAX(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 = 'abn react-anastom/graft')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY cost.hadm_id) AS t1
|
### Instruction:
Next Winter , is Prof. Scott Hershovitz teaching 633 ?
### 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 = 633 AND instructor.name LIKE '%Scott Hershovitz%' 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 = 2017
|
### Instruction:
TOP Haskell users in Oregon.
### 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 '%oregon%' AND TagName = 'haskell' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
### Instruction:
Are there 2 or 3 lectures for 381 a week usually ?
### 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 = 381 AND semester.semester_id = course_offering.semester ORDER BY semester.semester_id DESC LIMIT 10
|
### Instruction:
In Winter 2002 , how many professors teach MENAS 462 ?
### 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 = 'MENAS' AND course.number = 462 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 = 2002
|
### Instruction:
since 1 year ago, what was the minimum monthly number of patients diagnosed with pressure ulcer,stage nos?
### 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 = 'pressure ulcer,stage nos') AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY STRFTIME('%y-%m', diagnoses_icd.charttime)) AS t1
|
### Instruction:
tell me the name of the intake that patient 005-40894 had for the last time until 05/09/2103?
### Response:
|
SELECT intakeoutput.celllabel FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-40894')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2103-05-09' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
what was the last time of patient 6170 taking .9% normal saline on the current intensive care unit visit?
### Response:
|
SELECT inputevents_cv.charttime FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6170) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '.9% normal saline' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
what is the name of the medicine that was prescribed to patient 005-77687 for the first time through the dialysis route in the last month?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-77687')) AND medication.routeadmin = 'dialysis' AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
Average scores of last month's questions and answers.
### Response:
|
SELECT 1 AS No, 'Questions' AS "column", COUNT(Id) AS Total, AVG(CAST(Score AS FLOAT)) AS "average_score", STDEV(Score) AS "score_std_deviation" FROM Posts AS Q WHERE Q.ParentId IS NULL AND Q.CreationDate > DATEADD(m, -1, GETDATE()) UNION SELECT 2 AS No, 'Answers' AS "column", COUNT(Id) AS Total, AVG(CAST(Score AS FLOAT)) AS Average, STDEV(Score) AS Deviation FROM Posts AS A WHERE NOT A.ParentId IS NULL AND A.CreationDate > DATEADD(m, -1, GETDATE())
|
### Instruction:
what is the maximum heart rate of patient 739 today?
### Response:
|
SELECT MAX(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 739)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
In 2004 Spring , EEB 801 will have how many professors teaching it ?
### 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 = 'EEB' AND course.number = 801 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 = 2004
|
### Instruction:
how many days have elapsed since the first time during the current hospital encounter patient 005-48105 got a platelets 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 = '005-48105' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'platelets x 1000' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
Many answers by the same user on the same question. A hard-to-fix bug is that deleted users are counted as the same user
### Response:
|
SELECT MIN(a.Id) AS "post_link", a.OwnerUserId AS "user_link", MAX(a.OwnerDisplayName), COUNT(*) AS COUNT FROM Posts AS q INNER JOIN Posts AS a ON q.Id = a.ParentId WHERE q.PostTypeId = 1 AND a.PostTypeId = 2 AND (q.ClosedDate IS NULL OR '##excludeclosed:int?1##' = 0) AND (q.CommunityOwnedDate IS NULL OR '##excludewiki:int?1##' = 0) GROUP BY a.OwnerUserId, q.Id ORDER BY COUNT(*) DESC LIMIT 50
|
### Instruction:
The Core classes , who is teaching them 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:
How high is the fraction of posts closed as duplicates.
### Response:
|
SELECT CountTotal, CountClosedAsDuplicate, CAST(CountClosedAsDuplicate AS FLOAT) / CountTotal AS FractionClosedAsDuplicate FROM (SELECT (SELECT COUNT(*) FROM Posts AS p WHERE CreationDate > '2018-06-25' AND PostTypeId = 1 AND EXISTS(SELECT 1 FROM PostHistory AS ph WHERE ph.PostId = p.Id AND ph.PostHistoryTypeId = 10 AND ph.Comment = 101)) AS CountClosedAsDuplicate, (SELECT COUNT(*) FROM Posts AS p WHERE CreationDate > '2018-06-25' AND PostTypeId = 1) AS CountTotal) AS A
|
### Instruction:
What mornings does INTLSTD 489 meet ?
### 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 = 'INTLSTD' AND course.number = 489 AND semester.semester = 'semester0' AND semester.semester_id = course_offering.semester AND semester.year = year0
|
### Instruction:
Top User Of a Tag in a Location.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", TagName, 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 Location LIKE '%##Location##%' AND TagName = '##TagName##' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
### Instruction:
For the AMCULT 485 course what are the morning times ?
### 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 = 'AMCULT' AND course.number = 485 AND semester.semester = 'semester0' AND semester.semester_id = course_offering.semester AND semester.year = year0
|
### Instruction:
TeX.SX \\ corruption (grouped by id).
### Response:
|
SELECT COUNT(q.Body), q.OwnerUserId, q.OwnerDisplayName FROM Posts AS q WHERE (REPLACE(REPLACE(q.Body, '\\', ''), ' ', 'X') LIKE '%\XXXX%') AND q.OwnerUserId IN (SELECT p.OwnerUserId FROM Posts AS p WHERE (REPLACE(REPLACE(p.Body, '\\', ''), ' ', 'X') LIKE '%\XXXX%') AND q.AcceptedAnswerId != q.Id GROUP BY p.OwnerUserId, p.OwnerDisplayName HAVING COUNT(p.Body) < 75) GROUP BY q.OwnerUserId, q.OwnerDisplayName ORDER BY COUNT(q.Body) DESC
|
### 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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.