instruction
stringlengths 53
549
| output
stringlengths 30
2.33k
|
---|---|
### Instruction:
when was the last time that patient 022-78464 was prescribed a medication since 08/2100 via iv?
### 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 = '022-78464')) AND medication.routeadmin = 'iv' AND STRFTIME('%y-%m', medication.drugstarttime) >= '2100-08' ORDER BY medication.drugstarttime DESC LIMIT 1 |
### Instruction:
when did patient 030-47098 for the first time since 6 years ago receive treatment of hyperphosphatemia?
### Response:
| SELECT 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 = '030-47098')) AND treatment.treatmentname = 'treatment of hyperphosphatemia' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-6 year') ORDER BY treatment.treatmenttime LIMIT 1 |
### Instruction:
what is the minimum hospital cost for a drug with a name called nacl 0.9% bolus until 2 years ago?
### Response:
| SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT medication.patientunitstayid FROM medication WHERE medication.drugname = 'nacl 0.9% bolus')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.patienthealthsystemstayid) AS t1 |
### Instruction:
Percentage of AngularJS question without vote in the 5 days.
### Response:
| SELECT CASE WHEN Votes.Id IS NULL THEN 1 ELSE 0 END AS Unvoted, VoteTypes.Name, Posts.Score, Posts.Title FROM Posts LEFT JOIN Votes ON Posts.Id = Votes.PostId JOIN PostTags ON Posts.Id = PostTags.PostId JOIN Tags ON PostTags.TagId = Tags.Id JOIN VoteTypes ON VoteTypes.Id = Votes.VoteTypeId WHERE Posts.PostTypeId = 1 AND Posts.CreationDate > CURRENT_TIMESTAMP() - 5 AND Tags.TagName = 'angularjs' ORDER BY DAY(Posts.CreationDate) |
### Instruction:
is it patient 013-38992's heartrate ever greater than 74.0 in 12/2105?
### Response:
| SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-38992')) AND vitalperiodic.heartrate > 74.0 AND NOT vitalperiodic.heartrate IS NULL AND STRFTIME('%y-%m', vitalperiodic.observationtime) = '2105-12' |
### Instruction:
what was the last medication that patient 002-38474 was prescribed via iv push route since 128 months ago?
### Response:
| SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-38474')) AND medication.routeadmin = 'iv push' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-128 month') ORDER BY medication.drugstarttime DESC LIMIT 1 |
### Instruction:
how many times patient 84042 had received a lt heart angiocardiogram procedure since 6 years ago.
### 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 = 'lt heart angiocardiogram') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 84042) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year') |
### Instruction:
Tag synonyms where both tags have some questions. As far as I can tell, this happens when the tags were synonymized without merging
### Response:
| SELECT ts.SourceTagName AS "tags", t1.Count, ts.TargetTagName AS "tags", t2.Count, ts.CreationDate, ts.OwnerUserId AS "user_link", ts.ApprovalDate, ts.ApprovedByUserId AS "user_link" FROM TagSynonyms AS ts INNER JOIN Tags AS t1 ON ts.SourceTagName = t1.TagName INNER JOIN Tags AS t2 ON ts.TargetTagName = t2.TagName WHERE (t1.Count > 0) AND (NOT ts.ApprovalDate IS NULL) ORDER BY t1.Count DESC |
### Instruction:
Users by tags in DK.
### Response:
| SELECT u.Id AS "user_link", t.TagName, u.Reputation AS rep, u.DisplayName AS UserName FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id INNER JOIN Tags AS t ON t.Id = pt.TagId INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE (u.Location = 'Copenhagen' OR u.Location = 'Denmark') AND (t.TagName = 'python' OR t.TagName = 'docker' OR t.TagName = 'amazon-web-services') AND u.Reputation >= '400' GROUP BY u.Id, u.Reputation, u.DisplayName, t.TagName |
### Instruction:
what are the four most common lab tests among the patients aged 20s in 2103?
### 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 20 AND 29) AND STRFTIME('%y', labevents.charttime) = '2103' GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 4) |
### Instruction:
Top 100 posts with all comments upvoted. Inspired by this post: https://meta.stackexchange.com/questions/322566/say-to-the-new-contributor-that-upvoting-comments-does-almost-nothing-for-comm
### Response:
| SELECT Posts.Id AS "post_link" FROM Posts, Comments WHERE Posts.PostTypeId = 1 AND Posts.CommentCount > 3 AND Posts.Id = Comments.PostId AND Posts.OwnerUserId != Comments.UserId GROUP BY Posts.Id HAVING MIN(Comments.Score) = 1 AND MAX(Comments.Score) = 1 LIMIT 100 |
### Instruction:
today, did patient 016-38131 have any bulb #2 output?
### Response:
| SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-38131')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'bulb #2' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') |
### Instruction:
Most popular tags in 2019 group by month - Show only the tags used in more than 100 posts.
### Response:
| SELECT MONTH(p.CreationDate), pt.TagId, t.TagName, COUNT(pt.TagId) FROM (PostTags AS pt INNER JOIN Posts AS p ON p.Id = pt.PostId) INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE YEAR(p.CreationDate) = '2019' GROUP BY MONTH(p.CreationDate), pt.TagId, t.TagName HAVING COUNT(pt.TagId) > 100 ORDER BY MONTH(p.CreationDate), COUNT(pt.TagId) DESC |
### Instruction:
what was patient 5828 first height in their current 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 = 5828 AND admissions.dischtime IS NULL)) 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:
How many courses for each teacher? Show me a stacked bar chart The x-axis is teacher's first name and group by course description, and could you show by the Y-axis in ascending?
### Response:
| SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM GROUP BY CRS_DESCRIPTION, EMP_FNAME ORDER BY COUNT(EMP_FNAME) |
### Instruction:
how many times had patient 57899 since 2105 received a aortocor bypas-2 cor art?
### 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 = 'aortocor bypas-2 cor art') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 57899) AND STRFTIME('%y', procedures_icd.charttime) >= '2105' |
### Instruction:
tell me the daily average systemicdiastolic of patient 016-27397 during this hospital encounter.
### Response:
| SELECT AVG(vitalperiodic.systemicdiastolic) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-27397' AND patient.hospitaldischargetime IS NULL)) AND NOT vitalperiodic.systemicdiastolic IS NULL GROUP BY STRFTIME('%y-%m-%d', vitalperiodic.observationtime) |
### Instruction:
make a count of the number of times patient 003-48563 has received a immunosuppressive therapy - thymoglobulin during their last hospital encounter.
### Response:
| SELECT COUNT(*) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-48563' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND treatment.treatmentname = 'immunosuppressive therapy - thymoglobulin' |
### Instruction:
what is the daily minimum value of patient 010-11305's hco3 until 56 months ago?
### Response:
| SELECT MIN(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 = '010-11305')) AND lab.labname = 'hco3' AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-56 month') GROUP BY STRFTIME('%y-%m-%d', lab.labresulttime) |
### Instruction:
has ever been greater than 97.0 the sao2 of patient 022-151182 on the first intensive care unit visit?
### Response:
| SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-151182') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND vitalperiodic.sao2 > 97.0 AND NOT vitalperiodic.sao2 IS NULL |
### Instruction:
what was the first time patient 8005 had the minimum level of alanine aminotransferase (alt) when they visited the hospital last time?
### Response:
| SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8005 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'alanine aminotransferase (alt)') ORDER BY labevents.valuenum, labevents.charttime LIMIT 1 |
### Instruction:
who linked to my posts? (user construction).
### Response:
| SELECT lnk.CreationDate AS DateLinked, PostId AS linkin, RelatedPostId AS "post_link", p2.CreationDate AS origPostDate, p2.OwnerUserId AS "user_link", PostId AS "post_link", p1.CreationDate AS destPostDate, p1.OwnerUserId AS "user_link" FROM PostLinks AS lnk LEFT JOIN Posts AS p2 ON lnk.RelatedPostId = p2.Id LEFT JOIN Posts AS p1 ON lnk.PostId = p1.Id WHERE LinkTypeId = 1 AND p2.OwnerUserId = '##UserID##' |
### Instruction:
Next semester Dr. Stephen Tyndall will teach which classes ?
### Response:
| SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Stephen Tyndall%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
had patient 027-136480 go through a insulin - subcutaneous dose of regular insulin since 1 year ago?
### Response:
| SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-136480')) AND treatment.treatmentname = 'insulin - subcutaneous dose of regular insulin' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-1 year') |
### Instruction:
Does PHYSIOL 545 offer a section after 16:30 P.M. ?
### Response:
| SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '16:30' AND course.course_id = course_offering.course_id AND course.department = 'PHYSIOL' AND course.number = 545 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
what is the yearly minimum intake of volume (ml) dopamine that patient 006-78314 is getting?
### Response:
| SELECT MIN(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 = '006-78314')) AND intakeoutput.celllabel = 'volume (ml) dopamine' AND intakeoutput.cellpath LIKE '%intake%' GROUP BY STRFTIME('%y', intakeoutput.intakeoutputtime) |
### Instruction:
Which courses are Dr. Karen Acton teaching next semester ?
### Response:
| SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Karen Acton%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
had patient 027-165214 in 02/this year been allergic to any substance?
### Response:
| SELECT COUNT(*) > 0 FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-165214')) AND DATETIME(allergy.allergytime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', allergy.allergytime) = '02' |
### Instruction:
what was the last output that patient 23042 has had until 11/06/2104?
### Response:
| SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT outputevents.itemid FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23042)) AND STRFTIME('%y-%m-%d', outputevents.charttime) <= '2104-11-06' ORDER BY outputevents.charttime DESC LIMIT 1) |
### Instruction:
what is the minimum hospital cost that includes a procedure known as hormonal therapy (for varices) since 3 years ago?
### Response:
| SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'hormonal therapy (for varices)')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY cost.patienthealthsystemstayid) AS t1 |
### Instruction:
when was the heartrate of patient 028-52605 last measured until 1060 days ago?
### Response:
| SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-52605')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-1060 day') ORDER BY vitalperiodic.observationtime DESC LIMIT 1 |
### Instruction:
Does UKRAINE 252 only have sections before 10:00 , or are there any after ?
### Response:
| SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '10:00' AND course.course_id = course_offering.course_id AND course.department = 'UKRAINE' AND course.number = 252 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
since 1 year ago what was diagnosed with patient 26398 for the first time?
### Response:
| SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT diagnoses_icd.icd9_code FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26398) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY diagnoses_icd.charttime LIMIT 1) |
### Instruction:
did patient 52604 receive renal sclerosis nos diagnosis until 2104?
### Response:
| SELECT COUNT(*) > 0 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'renal sclerosis nos') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 52604) AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104' |
### Instruction:
count the number of times patient 016-38131 in their current hospital encounter has been prescribed with propofol 10 mg/1 ml 100ml sdv inj.
### Response:
| SELECT COUNT(*) FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-38131' AND patient.hospitaldischargetime IS NULL)) AND medication.drugname = 'propofol 10 mg/1 ml 100ml sdv inj' |
### Instruction:
did patient 022-3713 ever get an a respiration greater than 27.0 until 05/2105?
### Response:
| SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-3713')) AND vitalperiodic.respiration > 27.0 AND NOT vitalperiodic.respiration IS NULL AND STRFTIME('%y-%m', vitalperiodic.observationtime) <= '2105-05' |
### Instruction:
Nr of discrete users posting questions about dotnetnuke per month.
### Response:
| SELECT x.Yr, x.Qr, COUNT(x.Id) AS NrPosts FROM (SELECT p.Id, YEAR(p.CreationDate) AS Yr, TIME_TO_STR(p.CreationDate, '%q') AS Qr FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE p.CreationDate > '2015-01-01' AND t.TagName = 'dotnetnuke') AS x GROUP BY x.Yr, x.Qr ORDER BY x.Yr, x.Qr |
### Instruction:
Posts that had Bounties this Month.
### Response:
| SELECT P.Id AS "post_link", V.BountyAmount, (SELECT P2.Tags FROM Posts AS P2 WHERE P2.Id = P.ParentId) AS "tags" FROM Posts AS P, Votes AS V WHERE P.Id = V.PostId AND NOT V.BountyAmount IS NULL AND V.VoteTypeId = 9 AND DATEDIFF(month, V.CreationDate, GETDATE()) < 1 AND (SELECT P2.Tags FROM Posts AS P2 WHERE P2.Id = P.ParentId) LIKE '<%##tag1##%>' ORDER BY V.BountyAmount DESC, P.CreationDate DESC |
### Instruction:
when was the last time that patient 030-10559 has the minimum total co2 last month?
### Response:
| SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-10559')) AND lab.labname = 'total co2' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY lab.labresult, lab.labresulttime DESC LIMIT 1 |
### Instruction:
User with most questions asked.
### Response:
| SELECT Users.Id AS "user_link", QuestionCounts.PostsCount AS "number_of_questions", AnswerCounts.PostsCount AS "number_of_answers" FROM (SELECT OwnerUserId, COUNT(Id) AS PostsCount FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId) AS QuestionCounts, (SELECT OwnerUserId, COUNT(Id) AS PostsCount FROM Posts WHERE PostTypeId = 2 GROUP BY OwnerUserId) AS AnswerCounts, Users WHERE Users.Id = QuestionCounts.OwnerUserId AND Users.Id = AnswerCounts.OwnerUserId ORDER BY QuestionCounts.PostsCount DESC LIMIT 50 |
### Instruction:
what was the last time that patient 17694 was diagnosed with 31-32 comp wks gestation?
### Response:
| SELECT diagnoses_icd.charttime FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = '31-32 comp wks gestation') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17694) ORDER BY diagnoses_icd.charttime DESC LIMIT 1 |
### Instruction:
Is there a section of ECON 299 that is after 09:45 P.M. ?
### Response:
| SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '09:45' AND course.course_id = course_offering.course_id AND course.department = 'ECON' AND course.number = 299 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
Total Posts by Programming Languages Per Month - 2015.
### Response:
| SELECT COUNT(*) AS PostCount, T.TagName, YEAR(P.CreationDate) FROM Posts AS P INNER JOIN PostTags AS PT ON (P.Id = PT.PostId) INNER JOIN Tags AS T ON (PT.TagId = T.Id) WHERE YEAR(P.CreationDate) > 2014 AND P.CreationDate < '2015-12-01' AND NOT TagName LIKE '%rails%' GROUP BY YEAR(P.CreationDate), T.TagName HAVING COUNT(PostId) > 800 ORDER BY 2 DESC, 3 DESC, 1 DESC |
### Instruction:
TOP VBA PERFORMERS for date range. Top VBA/Excel Users for specified date range (or enter 0 in both for 'last 10 days with data').
Ranked by Overall: Sum of ( comments + score + (Answers * 2) )
### Response:
| SELECT c.UserId, COUNT(c.Id) AS qComments FROM Comments AS c JOIN Posts AS q ON c.PostId = q.Id WHERE c.CreationDate >= DATEADD(d, -10, (SELECT MAX(CreationDate) FROM Posts)) AND (q.Tags LIKE '%vba>%' OR q.Tags LIKE '%excel%') GROUP BY c.UserId ORDER BY COUNT(c.Id) DESC |
### Instruction:
retrieve patient ids of patients who are diagnosed with abn react-urinary cath in this year.
### Response:
| SELECT admissions.subject_id FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'abn react-urinary cath') AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) |
### Instruction:
show the total amount of patient 011-29258's output until 08/17/2100.
### Response:
| SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '011-29258')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2100-08-17' |
### Instruction:
Questions and answers in certain time period for specific tag.
### Response:
| SELECT Q.Id AS "post_link" FROM Posts AS Q INNER JOIN PostTags ON PostTags.PostId = Q.Id INNER JOIN Tags ON Tags.Id = PostTags.TagId INNER JOIN Users ON Users.Id = Q.OwnerUserId WHERE NOT Tags.TagName LIKE @Pattern AND (@Closed = 1 OR Q.ClosedDate IS NULL) AND (Q.CreationDate BETWEEN @From AND @To OR EXISTS(SELECT * FROM Posts AS A WHERE A.ParentId = Q.Id AND A.CreationDate BETWEEN @From AND @To)) GROUP BY Q.Id, Q.CreationDate ORDER BY Q.CreationDate |
### Instruction:
in their last hospital visit has patient 012-26564 been diagnosed with tricyclic overdose - with respiratory depression?
### Response:
| SELECT COUNT(*) > 0 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-26564' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND diagnosis.diagnosisname = 'tricyclic overdose - with respiratory depression' |
### Instruction:
what was the name of the specimen test patient 031-4423 received until 11/2104 for the last time?
### Response:
| SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4423')) AND STRFTIME('%y-%m', microlab.culturetakentime) <= '2104-11' ORDER BY microlab.culturetakentime DESC LIMIT 1 |
### Instruction:
count the number of times that patient 77177 in 2101 has received part sm bowel resect nec.
### Response:
| SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'part sm bowel resect nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 77177) AND STRFTIME('%y', procedures_icd.charttime) = '2101' |
### Instruction:
calculate the total amount of input patient 002-39753 had until 09/29/2102.
### Response:
| SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-39753')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2102-09-29' |
### Instruction:
Regarding the upper level electives for next Spring-Summer , which ones will be offered after 16:00 in the morning ?
### Response:
| SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course_offering.start_time > '16:00' AND course.course_id = course_offering.course_id AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Spring-Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2017 |
### Instruction:
tell me the five most frequent medical diagnoses until 1 year ago?
### Response:
| SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5) |
### Instruction:
Fastest Rep Gainers in Germany.
### Response:
| WITH GermanUsers AS (SELECT Id, Location, AboutMe, CreationDate, LastAccessDate, Reputation, CAST((LastAccessDate - CreationDate) AS FLOAT) AS TimeOnSite FROM Users WHERE LOWER(Location) LIKE '%germany%' OR LOWER(Location) LIKE '%deutschland%') SELECT Id AS "user_link", Location, AboutMe, TimeOnSite, Reputation, (CAST(Reputation AS FLOAT) / TimeOnSite) AS AvgRepPerDay FROM GermanUsers WHERE TimeOnSite > 0 AND YEAR(CreationDate) < 2017 ORDER BY AvgRepPerDay DESC LIMIT 100 |
### Instruction:
CW Answers (converted by moderator) that were later edited.
### Response:
| WITH CWAnswers AS (SELECT Posts.Id AS "post_link", Posts.LastEditDate, Posts.CommunityOwnedDate, Posts.LastEditorUserId AS "user_link" FROM PostHistory INNER JOIN Posts ON Posts.Id = PostHistory.PostId WHERE PostHistory.PostHistoryTypeId = 16 AND PostHistory.UserId != Posts.OwnerUserId AND Posts.PostTypeId = 2 AND Posts.CreationDate > '2016-09-01') SELECT * FROM CWAnswers WHERE CommunityOwnedDate > LastEditDate OR LastEditDate IS NULL |
### Instruction:
Are there any sections of EECS 767 offered after 07:30 P.M. ?
### Response:
| SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '07:30' AND course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 767 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
when is the first time that patient 028-11360 has had a sao2 measured on the last 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 = '028-11360') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.sao2 IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1 |
### Instruction:
When are the COMPLIT 374 classes in the 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 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 = 'COMPLIT' AND course.number = 374 ORDER BY semester.year DESC |
### Instruction:
Most popular data analysis languages by month and year.
### Response:
| SELECT YEAR(Posts.CreationDate) AS year, MONTH(Posts.CreationDate) AS month, Tags.TagName AS language, COUNT(Tags.TagName) AS posts FROM Posts, Tags WHERE Tags.TagName IN ('r', 'python', 'java', 'stata', 'matlab', 'sas', 'tableau') AND Posts.Tags LIKE ('%<' + Tags.TagName + '>%') GROUP BY Tags.TagName, YEAR(Posts.CreationDate), MONTH(Posts.CreationDate) ORDER BY Tags.TagName, YEAR(Posts.CreationDate), MONTH(Posts.CreationDate) |
### Instruction:
tag answer count (2014 - today).
### Response:
| SELECT t.TagName, t.Count AS tagCount, SUM(q.AnswerCount) AS answCnt FROM Posts AS q INNER JOIN Posts AS a ON q.AcceptedAnswerId = a.Id INNER JOIN PostTags AS pt ON pt.PostId = q.Id INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE q.Id != a.Id AND q.OwnerUserId != a.OwnerUserId AND q.CreationDate >= '2014-01-01' AND q.PostTypeId = 1 AND a.PostTypeId = 2 GROUP BY t.TagName, t.Count ORDER BY answCnt DESC |
### Instruction:
count the number of patients who since 2105 had been diagnosed with adv eff sedat/hypnot nec.
### Response:
| SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'adv eff sedat/hypnot nec') AND STRFTIME('%y', diagnoses_icd.charttime) >= '2105') |
### Instruction:
List a user's rejected suggested edits. List all the rejected suggested edits proposed by a given user.
### Response:
| SELECT 'site://suggested-edits/' + CAST(s.Id AS TEXT(20)) + '|' + CASE LENGTH(LTRIM(s.Comment)) WHEN 0 THEN 'none' ELSE s.Comment END AS "suggested_edit", s.PostId AS "post_link", s.CreationDate AS "creation_date", s.RejectionDate AS "rejection_date" FROM SuggestedEdits AS s WHERE s.OwnerUserId = '##UserId##' AND NOT s.RejectionDate IS NULL ORDER BY s.RejectionDate DESC |
### Instruction:
What are the forenames and surnames of drivers who participated in the races named Australian Grand Prix but not the races named Chinese Grand Prix?
### Response:
| SELECT T3.forename, T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename, T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix" |
### Instruction:
In every semester , can you take ENDODONT 651 ?
### Response:
| SELECT COUNT(*) > 0 FROM semester WHERE NOT semester IN (SELECT DISTINCT SEMESTERalias1.semester FROM course AS COURSEalias0, course_offering AS COURSE_OFFERINGalias0, semester AS SEMESTERalias1 WHERE COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id AND COURSEalias0.department = 'ENDODONT' AND COURSEalias0.number = 651 AND SEMESTERalias1.semester_id = COURSE_OFFERINGalias0.semester) |
### Instruction:
Tags which no longer exists (ordered by number of questions).
### Response:
| WITH tagshistory_cte AS (SELECT Id AS phid, REPLACE(value, '>', '') AS TagName FROM PostHistory JOIN LATERAL STRING_SPLIT(Text, '<') WHERE PostHistoryTypeId IN (3, 6, 9) AND LENGTH(value) > 0) SELECT th.TagName, COUNT(DISTINCT ph.PostId) AS "count" FROM tagshistory_cte AS th INNER JOIN PostHistory AS ph ON ph.Id = th.phid WHERE (th.TagName NOT IN (SELECT TagName FROM Tags)) GROUP BY th.TagName ORDER BY COUNT(DISTINCT ph.PostId) DESC |
### Instruction:
For ITALIAN 316 , is there any section after 10:00 ?
### Response:
| SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '10:00' AND course.course_id = course_offering.course_id AND course.department = 'ITALIAN' AND course.number = 316 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
what is the monthly average amount of cortisol patient 017-66654 has since 6 years ago?
### Response:
| SELECT AVG(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-66654')) AND lab.labname = 'cortisol' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY STRFTIME('%y-%m', lab.labresulttime) |
### Instruction:
Which is the first paper by richard bellman ?
### Response:
| SELECT DISTINCT paper.paperid, paper.year FROM author, paper, writes WHERE author.authorname = 'richard bellman' AND paper.year = (SELECT MIN(PAPERalias1.year) FROM author AS AUTHORalias1, paper AS PAPERalias1, writes AS WRITESalias1 WHERE AUTHORalias1.authorname = 'richard bellman' AND WRITESalias1.authorid = AUTHORalias1.authorid AND WRITESalias1.paperid = PAPERalias1.paperid) AND writes.authorid = author.authorid AND writes.paperid = paper.paperid |
### Instruction:
What prerequisites do I need for EHS 616 and 615 ?
### Response:
| SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE (COURSE_1.number = 616 OR COURSE_1.number = 615) AND COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'EHS' |
### Instruction:
what was the total number of outputs patient 56490 had on 09/10/last year?
### Response:
| SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 56490)) AND DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', outputevents.charttime) = '09-10' |
### Instruction:
since 27 months ago what was the first time of patient 031-24513's microbiology test?
### Response:
| SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-24513')) AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-27 month') ORDER BY microlab.culturetakentime LIMIT 1 |
### Instruction:
what is the count of times that patient 77987 had received a specific gravity lab test in 09/last year.
### Response:
| SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'specific gravity') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 77987) AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', labevents.charttime) = '09' |
### Instruction:
when they came to the hospital first time, has patient 9038 had a sm bowel endoscopy nec procedure?
### Response:
| SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'sm bowel endoscopy nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9038 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) |
### Instruction:
did patient 005-87465 had output (ml)-chest tube #1 pleural left output on the current intensive care unit visit?
### Response:
| SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-87465') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output (ml)-chest tube #1 pleural left' |
### Instruction:
what was the name of the specimen test that patient 031-22988 was first to receive until 32 months ago?
### Response:
| SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-22988')) AND DATETIME(microlab.culturetakentime) <= DATETIME(CURRENT_TIME(), '-32 month') ORDER BY microlab.culturetakentime LIMIT 1 |
### Instruction:
how many days have passed since patient 10855 stayed in the ward 50 in their current hospital visit for the last time?
### Response:
| SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10855 AND admissions.dischtime IS NULL)) AND transfers.wardid = 50 ORDER BY transfers.intime DESC LIMIT 1 |
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of manager_id over the job_id , and group by attribute job_id by a bar chart, I want to order in desc by the mean manager id please.
### Response:
| SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(MANAGER_ID) DESC |
### Instruction:
What upper-level electives do n't meet on Monday or Friday and are offered next semester ?
### Response:
| SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course_offering.friday = 'N' AND course_offering.monday = 'N' AND course.course_id = course_offering.course_id AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
when did patient 021-239662 first receive an dka diagnosis during their last hospital encounter?
### 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 = '021-239662' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND diagnosis.diagnosisname = 'dka' ORDER BY diagnosis.diagnosistime LIMIT 1 |
### Instruction:
Users who actively participate (at least 1 question and answer) By Join Date.
### Response:
| SELECT YEAR(Users.CreationDate) AS cYear, MONTH(Users.CreationDate) AS cMonth, COUNT(*) AS askedAndAnswered FROM (SELECT DISTINCT OwnerUserId FROM Posts WHERE PostTypeId = 1) AS P1 JOIN (SELECT DISTINCT OwnerUserId FROM Posts WHERE PostTypeId = 2) AS P2 ON P1.OwnerUserId = P2.OwnerUserId JOIN Users ON P1.OwnerUserId = Users.Id GROUP BY YEAR(Users.CreationDate), MONTH(Users.CreationDate) ORDER BY 1, 2 |
### Instruction:
what is the first value of the bedside glucose of patient 002-58884 a month before?
### Response:
| SELECT 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 = '002-58884')) AND lab.labname = 'bedside glucose' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY lab.labresulttime LIMIT 1 |
### Instruction:
what is the yearly minimum amount of bilirubin, total, ascites patient 31243 has since 2104?
### Response:
| SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31243) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'bilirubin, total, ascites') AND STRFTIME('%y', labevents.charttime) >= '2104' GROUP BY STRFTIME('%y', labevents.charttime) |
### Instruction:
what was the first time patient 030-75705 had the minimum level of -eos since 09/2105?
### Response:
| SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-75705')) AND lab.labname = '-eos' AND STRFTIME('%y-%m', lab.labresulttime) >= '2105-09' ORDER BY lab.labresult, lab.labresulttime LIMIT 1 |
### Instruction:
the temperature of patient 004-13127 had been less than 37.444 on the last icu visit?
### 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 = '004-13127') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND vitalperiodic.temperature < 37.444 AND NOT vitalperiodic.temperature IS NULL |
### Instruction:
has the temperature of patient 004-13127 on the last icu visit been less than 37.444?
### 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 = '004-13127') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND vitalperiodic.temperature < 37.444 AND NOT vitalperiodic.temperature IS NULL |
### Instruction:
when did patient 030-28944 receive a test for creatinine for the last time this month?
### Response:
| SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-28944')) AND lab.labname = 'creatinine' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY lab.labresulttime DESC LIMIT 1 |
### Instruction:
what was the drug that in 04/this year patient 72198 was prescribed via the ih route for the last time?
### Response:
| SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 72198) AND prescriptions.route = 'ih' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '04' ORDER BY prescriptions.startdate DESC LIMIT 1 |
### Instruction:
has serum creatinine >= 1.5 mg / dl ( >= 133umol / l ) if male or >= 1.4 mg / dl ( >= 124 umol / l ) if female and / or estimated glomerular filtration rate ( egfr ) < 60 ml / min / 1.73 m^2 at screening.
### Response:
| SELECT * FROM table_dev_27 WHERE (serum_creatinine >= 1.5 AND gender = 'male') OR (serum_creatinine >= 1.4 AND gender = 'female') OR estimated_glomerular_filtration_rate_egfr < 60 |
### Instruction:
what did patient 14203 receive for his or her first procedure since 6 years ago?
### Response:
| SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT procedures_icd.icd9_code FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14203) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year') ORDER BY procedures_icd.charttime LIMIT 1) |
### Instruction:
what is the three most frequently ordered procedure for patients of 50s in the last year?
### Response:
| SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 50 AND 59) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3 |
### Instruction:
what is the last specimen test given to patient 031-16123 since 08/2104?
### Response:
| SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-16123')) AND STRFTIME('%y-%m', microlab.culturetakentime) >= '2104-08' ORDER BY microlab.culturetakentime DESC LIMIT 1 |
### Instruction:
what's the number of patients who had a nepro intake until 2103?
### 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 = 'nepro' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y', inputevents_cv.charttime) <= '2103')) |
### Instruction:
what is the name of the specimen test that patient 031-23724 was given for the last time when they came to the hospital first time?
### Response:
| SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-23724' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) ORDER BY microlab.culturetakentime DESC LIMIT 1 |
### Instruction:
what is the average total hospital cost, which includes polyuria - post atn diuresis until 2102?
### Response:
| SELECT AVG(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 = 'polyuria - post atn diuresis')) AND STRFTIME('%y', cost.chargetime) <= '2102' GROUP BY cost.patienthealthsystemstayid) AS t1 |
### Instruction:
how many hours have passed since the last time patient 27172 stayed in ward 15 during the current hospital visit.
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27172 AND admissions.dischtime IS NULL)) AND transfers.wardid = 15 ORDER BY transfers.intime DESC LIMIT 1 |
### Instruction:
i need information on ground transportation between airport and downtown in the city of BOS
### Response:
| SELECT DISTINCT ground_service.transport_type FROM airport, airport_service, city AS CITY_0, city AS CITY_1, ground_service WHERE airport.airport_code = airport_service.airport_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = airport_service.city_code AND CITY_1.city_name = 'BOSTON' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_0.city_code |
### Instruction:
how many days have elapsed since the last time patient 027-203413 was given a procedure in this hospital visit?
### 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-203413' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime DESC LIMIT 1 |
### Instruction:
votes on all posts by a specific user.
### Response:
| SELECT pt.Name AS PostType, vt.Name AS VoteType, COUNT(v.Id) AS NumVotes FROM Posts AS p LEFT JOIN Votes AS v ON p.Id = v.PostId LEFT JOIN VoteTypes AS vt ON vt.Id = v.VoteTypeId LEFT JOIN PostTypes AS pt ON pt.Id = p.PostTypeId WHERE p.OwnerUserId = '##UserId##' AND p.DeletionDate IS NULL AND p.ClosedDate IS NULL GROUP BY pt.Name, vt.Name HAVING COUNT(v.Id) > 0 ORDER BY pt.Name DESC, vt.Name DESC |
### Instruction:
what was the name of the output which patient 009-424 had for the last time on the last intensive care unit visit?
### 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 = '009-424') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND intakeoutput.cellpath LIKE '%output%' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1 |
### Instruction:
when has patient 021-75161 had the first intake on the last intensive care unit 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 = '021-75161') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.