instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
what is the total dose of sc 24 fe ng that patient 6170 received on the current intensive care unit visit?
### Response:
|
SELECT SUM(inputevents_cv.amount) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6170) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sc 24 fe ng' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
what is the maximum hospital cost for a procedure that involves cardiac mapping during this year?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'cardiac mapping')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY cost.hadm_id) AS t1
|
### Instruction:
React vs Angular popularity over time.
### Response:
|
SELECT YEAR(p.CreationDate), TagName, COUNT(1) FROM Posts AS p, PostTags AS pt, Tags AS t WHERE p.Id = pt.PostId AND pt.TagId = t.Id AND TagName IN ('angularjs', 'reactjs', 'vue.js', 'react.js', 'AngularJs', 'Aurelia', 'knockout.js', 'ember.js', 'backbone.js', 'Jqueryjs') AND p.CreationDate > '2010-01-01' AND p.CreationDate < '2017-09-01' GROUP BY YEAR(p.CreationDate), TagName ORDER BY 1
|
### Instruction:
when did the first intake of patient 5142 have been on last month/03?
### 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 = 5142)) AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', inputevents_cv.charttime) = '03' ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
Will Prof. David Moon teach 597 next semester ?
### Response:
|
SELECT COUNT(*) > 0 FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 597 AND instructor.name LIKE '%David Moon%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
what is the maximum value of mch in patient 006-7325's body in 04/last year?
### Response:
|
SELECT MAX(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-7325')) AND lab.labname = 'mch' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', lab.labresulttime) = '04'
|
### Instruction:
since 1058 days ago, what was last value of systemicsystolic for patient 027-4309?
### Response:
|
SELECT vitalperiodic.systemicsystolic FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-4309')) AND NOT vitalperiodic.systemicsystolic IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-1058 day') ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
Down votes cast in past 30 days on answers less than 30 days old answering questions more than 60 da.
### Response:
|
SELECT COUNT(*) FROM Votes JOIN Posts AS p1 ON Votes.PostId = p1.Id JOIN Posts AS p2 ON p1.ParentId = p2.Id WHERE Votes.VoteTypeId IN (3) AND Votes.CreationDate >= DATEADD(DAY, -30, GETDATE()) AND p1.PostTypeId = 2 AND p1.CreationDate >= DATEADD(DAY, -30, GETDATE()) AND NOT p1.ParentId IS NULL AND p2.PostTypeId = 1 AND p2.CreationDate <= DATEADD(DAY, -60, GETDATE())
|
### Instruction:
had patient 67468 ever had some pericardial's in 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 = 67468)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'pericardial' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m', outputevents.charttime) = '2105-12'
|
### Instruction:
when does patient 10425 have received a urine microbiology test for the first time in 09/last year?
### Response:
|
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10425) AND microbiologyevents.spec_type_desc = 'urine' AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microbiologyevents.charttime) = '09' ORDER BY microbiologyevents.charttime LIMIT 1
|
### Instruction:
does the sao2 of patient 016-34108 have been greater than 82.0 today?
### 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 = '016-34108')) AND vitalperiodic.sao2 > 82.0 AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
List the names of the browser that are compatible with both 'CACHEbox' and 'Fasterfox'.
### Response:
|
SELECT T3.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T1.name = 'CACHEbox' INTERSECT SELECT T3.name FROM web_client_accelerator AS T1 JOIN accelerator_compatible_browser AS T2 ON T2.accelerator_id = T1.id JOIN browser AS T3 ON T2.browser_id = T3.id WHERE T1.name = 'Fasterfox'
|
### Instruction:
had patient 30763 until 1 year ago been diagnosed with delirium d/t other cond?
### 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 = 'delirium d/t other cond') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 30763) AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year')
|
### Instruction:
Who will be teaching next semester 's ARABAM 498 ?
### Response:
|
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN course ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'ARABAM' AND course.number = 498 AND semester.semester = 'FA' AND semester.year = 2016
|
### Instruction:
has 3% citrate been administered to patient 18866 on the first hospital visit?
### 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 = 18866 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '3% citrate' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
during a year before what is the four most commonly taken lab test for patients 60 or above?
### 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 >= 60) AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
what was the five most commonly taken laboratory test until 4 years ago for a patient aged 30s?
### Response:
|
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t1.itemid FROM (SELECT labevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
calculate the total amount of patient 007-10615's continuous infusion meds intake on the first intensive care unit visit.
### 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 = '007-10615') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND intakeoutput.celllabel = 'continuous infusion meds' AND intakeoutput.cellpath LIKE '%intake%'
|
### Instruction:
what was the name of the organism found during the first other microbiology examination of patient 031-23724 in their last hospital encounter?
### Response:
|
SELECT microlab.organism FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-23724' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND microlab.culturesite = 'other' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
when was the first meperidine hcl prescription given to patient 013-21980 in 08/2104.
### 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 = '013-21980')) AND medication.drugname = 'meperidine hcl' AND STRFTIME('%y-%m', medication.drugstarttime) = '2104-08' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
count the number of times patient 002-34744 had a drain 1 output ml output today.
### Response:
|
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-34744')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'drain 1 output ml' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
simple example for CROSS APPLY.
### Response:
|
SELECT * FROM (VALUES ('Cesc F bregas', DATE('4 May 1987'), DATE('28 October 2003')), ('Theo Walcott', DATE('16 March 1989'), DATE('19 August 2006')), ('Jack Wilshere', DATE('1 January 1992'), DATE('13 September 2008')), ('Thierry Henry', DATE('17 August 1977'), DATE('7 August 1999'))) AS p(Name, DoB, Debut) JOIN LATERAL (SELECT p.DoB AS startdate, p.Debut AS enddate) AS working
|
### Instruction:
had patient 035-19333 been prescribed cordarone, lactated ringers or lantus last year?
### 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 = '035-19333')) AND medication.drugname IN ('cordarone', 'lactated ringers', 'lantus') AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
Tag wiki and excerpt edits per user.
### Response:
|
SELECT usere AS "user_link", TagWiki, Excerpt FROM (SELECT COUNT(*) AS TagWiki, h.OwnerUserId AS userw FROM Posts AS p JOIN SuggestedEdits AS h ON p.Id = h.PostId WHERE p.PostTypeId = 5 GROUP BY h.OwnerUserId) AS t1 RIGHT JOIN (SELECT COUNT(*) AS Excerpt, h.OwnerUserId AS usere FROM Posts AS p JOIN SuggestedEdits AS h ON p.Id = h.PostId WHERE p.PostTypeId = 5 GROUP BY h.OwnerUserId) AS t2 ON t1.userw = t2.usere ORDER BY Excerpt DESC
|
### Instruction:
how many times does patient 030-28944 get a analgesic other (volume) intake since 1118 days 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 = '030-28944')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'analgesic other (volume)' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-1118 day')
|
### Instruction:
Unanswered questions tagged with Visio (but not 'vision').
### Response:
|
WITH TargetTags AS (SELECT Tags.Id FROM Tags WHERE Tags.TagName LIKE '%visio%' AND NOT Tags.TagName LIKE '%vision%') SELECT Posts.Tags, Posts.Id, 'http://stackoverflow.com/questions/' + REPLACE(STR(Posts.Id), ' ', '') AS PostURL, Posts.Title, Posts.OwnerDisplayName, Posts.CreationDate, Posts.Body FROM Posts INNER JOIN PostTags ON Posts.Id = PostTags.PostId INNER JOIN TargetTags ON PostTags.TagId = TargetTags.Id WHERE Posts.AcceptedAnswerId IS NULL AND Posts.ClosedDate IS NULL ORDER BY Posts.CreationDate DESC
|
### Instruction:
what were the first outputs of patient 027-214052 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 = '027-214052')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2103-05-09' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
had patient 016-12011 had othroutputtotal output since 02/24/2100.
### 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-12011')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'othroutputtotal' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2100-02-24'
|
### Instruction:
For RCLANG 320 next semester , who is teaching it ?
### Response:
|
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN course ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'RCLANG' AND course.number = 320 AND semester.semester = 'FA' AND semester.year = 2016
|
### Instruction:
what is the daily average amount of calcium of patient 006-105495 during this month?
### 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 = '006-105495')) AND lab.labname = 'calcium' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') GROUP BY STRFTIME('%y-%m-%d', lab.labresulttime)
|
### Instruction:
what's patient 27362's maximum value of bicarbonate in 06/last year?
### Response:
|
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27362) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'bicarbonate') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', labevents.charttime) = '06'
|
### Instruction:
what was the first procedure time of patient 41393 for spinal tap 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 = 'spinal tap') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 41393) AND STRFTIME('%y', procedures_icd.charttime) <= '2103' ORDER BY procedures_icd.charttime LIMIT 1
|
### Instruction:
how many times patient 033-10145 had been prescribed pravastatin sodium 40 mg po tabs a year before.
### 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 = '033-10145')) AND medication.drugname = 'pravastatin sodium 40 mg po tabs' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
count the number of patients who had been given a rigid proctosigmoidoscpy procedure this year.
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'rigid proctosigmoidoscpy') AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
|
### Instruction:
Could you tell me what classes will be taught by Dr. Paige Andersson 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 '%Paige Andersson%' 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:
tell me the name of the intake that patient 23066 had for the first time until 617 days ago?
### Response:
|
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT inputevents_cv.itemid FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23066)) AND DATETIME(inputevents_cv.charttime) <= DATETIME(CURRENT_TIME(), '-617 day') ORDER BY inputevents_cv.charttime LIMIT 1)
|
### Instruction:
what was the name of the intake that patient 013-38992 has first had during yesterday?
### 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 = '013-38992')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
what is the minimum hospital bill that covers a procedure called prophylactic antibacterials - for endocarditis in 2105?
### 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 = 'prophylactic antibacterials - for endocarditis')) AND STRFTIME('%y', cost.chargetime) = '2105' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
until 2104 patient 015-72608 had been prescribed ondansetron 2 mg/1 ml 2ml sdv inj?
### 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 = '015-72608')) AND medication.drugname = 'ondansetron 2 mg/1 ml 2ml sdv inj' AND STRFTIME('%y', medication.drugstarttime) <= '2104'
|
### Instruction:
what is the maximum cost of the hospital which involves aortic valve disorder in 2105?
### 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 = 'aortic valve disorder')) AND STRFTIME('%y', cost.chargetime) = '2105' GROUP BY cost.hadm_id) AS t1
|
### Instruction:
what is the lab test given to patient 009-12221 for the last time in 10/last year?
### Response:
|
SELECT lab.labname FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-12221')) AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', lab.labresulttime) = '10' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
when was patient 002-74856 first measured a systemicmean since 08/30/2105?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-74856')) AND NOT vitalperiodic.systemicmean IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) >= '2105-08-30' ORDER BY vitalperiodic.observationtime LIMIT 1
|
### Instruction:
when was the last time that the heartrate of patient 030-52327 was measured or taken today?
### 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 = '030-52327')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
what is the maximum hospital cost that involves a procedure known as a cl reduct mandible fx until 2104?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'cl reduct mandible fx')) AND STRFTIME('%y', cost.chargetime) <= '2104' GROUP BY cost.hadm_id) AS t1
|
### Instruction:
has patient 002-52932 on 03/08/2100 excreted any voided amount.
### 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 = '002-52932')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'voided amount' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2100-03-08'
|
### Instruction:
what is the average number of patients diagnosed with diseases of lips monthly until 2104?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT COUNT(DISTINCT diagnoses_icd.hadm_id) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'diseases of lips') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104' GROUP BY STRFTIME('%y-%m', diagnoses_icd.charttime)) AS t1
|
### Instruction:
when was the first time that patient 017-61209 has received cardiology consultation during the last year?
### 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 = '017-61209')) AND treatment.treatmentname = 'cardiology consultation' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
when did patient 027-178495 take an intake for the last time until 230 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 = '027-178495')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-230 day') ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
What is the name of each dorm that has a TV Lounge but no study rooms?
### Response:
|
SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid WHERE T3.amenity_name = 'Study Room'
|
### Instruction:
Anonymous feedback on a user's posts.
### Response:
|
SELECT pf.PostId AS "post_link", SUM(CASE WHEN pf.VoteTypeId = 2 THEN 1 ELSE NULL END) AS UpFeedback, SUM(CASE WHEN pf.VoteTypeId = 3 THEN 1 ELSE NULL END) AS DownFeedback, SUM(CASE pf.VoteTypeId WHEN 2 THEN 1 WHEN 3 THEN -1 END) AS Score FROM PostFeedback AS pf JOIN Posts AS p ON p.Id = pf.PostId WHERE p.OwnerUserId = '##userID##' GROUP BY pf.PostId ORDER BY SUM(CASE WHEN pf.VoteTypeId = 2 THEN 1 ELSE NULL END) DESC
|
### Instruction:
since 65 months ago, list the monthly maximum heartrate of patient 017-70504.
### Response:
|
SELECT MAX(vitalperiodic.heartrate) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-70504')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-65 month') GROUP BY STRFTIME('%y-%m', vitalperiodic.observationtime)
|
### Instruction:
what was the name of procedure, that patient 51698 was first received during this year?
### 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 = 51698) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY procedures_icd.charttime LIMIT 1)
|
### Instruction:
tell me the top five procedures that were the most common the previous year.
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
Votes to old posts by age. (From 100 answers you get roughly 1 vote per week)
### Response:
|
WITH RecentVotes AS (SELECT PostId, COUNT(Id) AS VoteCount FROM Votes WHERE DATEDIFF(week, CreationDate, GETDATE()) = @base GROUP BY PostId), AnswerAge AS (SELECT Id AS PostId, DATEDIFF(week, CreationDate, GETDATE()) AS Age FROM Posts WHERE PostTypeId = 2) SELECT Age, SUM(VoteCount) * 1.0 / COUNT(AnswerAge.PostId) AS PostVotes FROM AnswerAge LEFT OUTER JOIN RecentVotes ON AnswerAge.PostId = RecentVotes.PostId WHERE Age > @base GROUP BY Age ORDER BY Age
|
### Instruction:
what was the name of the drug that was prescribed to patient 030-47098 for the last time when they came to the hospital first time via subcutan route?
### 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 = '030-47098' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND medication.routeadmin = 'subcutan' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
has the sao2 of patient 027-139111 since 573 days ago been less than 99.0?
### 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 = '027-139111')) AND vitalperiodic.sao2 < 99.0 AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-573 day')
|
### Instruction:
what was the lisinopril dose that was prescribed to patient 26995 in 11/last year for the first time?
### Response:
|
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26995) AND prescriptions.drug = 'lisinopril' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', prescriptions.startdate) = '11' ORDER BY prescriptions.startdate LIMIT 1
|
### Instruction:
List of Users in a given location and keyword contained in 'about me'. This query lists all users in a given location and keyword sorted by reputation.
Enter 'Germany' or 'Deutschland' in the location field.
Enter 'Java' in the keyword field.
Press 'Run Query'
credits to https://data.stackexchange.com/meta.stackexchange/query/3631/list-of-users-in-a-given-location
### Response:
|
SELECT Id AS "user_link", Location, WebsiteUrl, Reputation FROM Users WHERE LOWER(Location) LIKE LOWER('%##location##%') AND LOWER(AboutMe) LIKE LOWER('%##keyword##%') ORDER BY Reputation DESC
|
### Instruction:
Questions asked per day in Sun-Sat week periods.
### Response:
|
SELECT CAST(DATEADD(DAY, 1 - DATEPART(WEEKDAY, CreationDate), CreationDate) AS DATE) AS "week_of", ROUND(CAST(COUNT(*) AS FLOAT) / 7, 2) FROM Posts WHERE PostTypeId = 1 AND CAST(CreationDate AS DATE) < '2013-01-01' GROUP BY CAST(DATEADD(DAY, 1 - DATEPART(WEEKDAY, CreationDate), CreationDate) AS DATE) ORDER BY CAST(DATEADD(DAY, 1 - DATEPART(WEEKDAY, CreationDate), CreationDate) AS DATE)
|
### Instruction:
Questions tagged geometry but without the frequent geometry-related top-level tags.
### Response:
|
SELECT q.Id AS "post_link", q.Tags, q.CreationDate FROM Posts AS q INNER JOIN PostTags AS pt ON q.Id = pt.PostId INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE t.TagName = '##tagName:string?geometry##' AND NOT (q.Tags LIKE '%<dg.differential-geometry>%') AND NOT (q.Tags LIKE '%<mg.metric-geometry>%') AND NOT (q.Tags LIKE '%<ag.algebraic-geometry>%') AND NOT (q.Tags LIKE '%<gt.geometric-topology>%') ORDER BY q.CreationDate DESC
|
### Instruction:
what is patient 033-22108's monthly average level of ionized calcium this year?
### 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 = '033-22108')) AND lab.labname = 'ionized calcium' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY STRFTIME('%y-%m', lab.labresulttime)
|
### Instruction:
what is the minimum total hospital cost involving a procedure called a int insert dual-cham dev in 2101?
### Response:
|
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'int insert dual-cham dev')) AND STRFTIME('%y', cost.chargetime) = '2101' GROUP BY cost.hadm_id) AS t1
|
### Instruction:
what was the first glucose in patient 10624 in 08/last year?
### Response:
|
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10624) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'glucose') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', labevents.charttime) = '08' ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
what's the maximum hospital cost if there is malign neopl prostate until 2102?
### 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 = 'malign neopl prostate')) AND STRFTIME('%y', cost.chargetime) <= '2102' GROUP BY cost.hadm_id) AS t1
|
### Instruction:
Who 's this Spring 's CZECH 142 teacher ?
### Response:
|
SELECT DISTINCT instructor.name FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'CZECH' AND course.number = 142 AND semester.semester = 'Spring' AND semester.year = 2016
|
### Instruction:
what were the top five most frequently performed lab tests among patients aged 40s since 3 years ago?
### 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 40 AND 49) AND DATETIME(labevents.charttime) >= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
R Answered Posts Since 2015.
### Response:
|
SELECT p.Id, p.CreationDate, p.Score, p.ViewCount, p.OwnerUserId, p.Title, p.Tags, p.AnswerCount, CONCAT('https://stackoverflow.com/questions/', CAST(p.Id AS TEXT(30))) AS url FROM Posts AS p JOIN PostTags AS pt ON p.Id = pt.PostId JOIN Tags AS t ON t.Id = pt.TagId AND t.TagName = 'r' WHERE NOT p.AcceptedAnswerId IS NULL AND p.CreationDate >= '2015-01-01' AND p.ParentId IS NULL ORDER BY p.Score DESC LIMIT 50000
|
### Instruction:
how many days has it been since the first time during the current hospital visit that patient 006-76924 had received a mcv laboratory 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 = '006-76924' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'mcv' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
what was the first sputum microbiology test performed in 05/last year for patient 54281?
### Response:
|
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 54281) AND microbiologyevents.spec_type_desc = 'sputum' AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microbiologyevents.charttime) = '05' ORDER BY microbiologyevents.charttime LIMIT 1
|
### Instruction:
what was the top three of the most frequent procedures during this year?
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
|
### Instruction:
What classes does Prof. Ej Westlake teach in Spring 2005 ?
### 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 '%Ej Westlake%' 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 = 2005
|
### Instruction:
iPhone thread volume, page views, unique OPs by month.
### Response:
|
SELECT COUNT(*) AS Volume, SUM(ViewCount) AS PageViews, COUNT(DISTINCT OwnerUserId) AS UniqueOPs, TIME_TO_STR(P.CreationDate, '%Y') AS "year", TIME_TO_STR(P.CreationDate, '%m') AS Month FROM Posts AS P WHERE ('tags' LIKE '%<iphone%') AND PostTypeId = 1 AND CommunityOwnedDate IS NULL AND ClosedDate IS NULL GROUP BY TIME_TO_STR(P.CreationDate, '%YEAR'), TIME_TO_STR(P.CreationDate, '%-mONT%-H') ORDER BY 'year', Month
|
### Instruction:
when was patient 002-41152 prescribed medication via injection route, for the first time last month?
### 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 = '002-41152')) AND medication.routeadmin = 'injection' AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
Google app engine thread volume with accepted answers by month.
### Response:
|
SELECT COUNT(*) AS AnsweredVolume, TIME_TO_STR(P.CreationDate, '%Y') AS "year", TIME_TO_STR(P.CreationDate, '%m') AS Month FROM Posts AS P WHERE (Tags LIKE '%<google-app-engine>%' OR Tags LIKE '%<google-app-engine-patch>%') AND PostTypeId = 1 AND CommunityOwnedDate IS NULL AND ClosedDate IS NULL AND AcceptedAnswerId > 0 GROUP BY TIME_TO_STR(P.CreationDate, '%YEAR'), TIME_TO_STR(P.CreationDate, '%-mONT%-H') ORDER BY 'year', Month
|
### Instruction:
Posts from which an initial tag was removed.
### Response:
|
SELECT p.Id AS "post_link", REPLACE(SUBSTRING(i.Text, 2, LENGTH(i.Text) - 2), '><', ' ') AS "initial_tags", REPLACE(SUBSTRING(p.Tags, 2, LENGTH(p.Tags) - 2), '><', ' ') AS "current_tags" FROM Posts AS p INNER JOIN PostHistory AS i ON p.Id = i.PostId WHERE i.PostHistoryTypeId = 3 AND i.Text LIKE '%<' + '##Tag##' + '>%' AND NOT p.Tags LIKE '%<' + '##Tag##' + '>%' ORDER BY p.Id
|
### Instruction:
when was the first time patient 021-83942's intake time since 2179 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 = '021-83942')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-2179 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
when was the first test performed in 04/last year in the lab on patient 002-75209?
### 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-75209')) AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', lab.labresulttime) = '04' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
how many days have elapsed since patient 006-158338 had received an ph lab test for the first time in the current hospital encounter?
### 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 = '006-158338' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'ph' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
since 5 years ago patient 16571 was diagnosed with a special symptom nec/nos?
### 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 = 'special symptom nec/nos') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 16571) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-5 year')
|
### Instruction:
i would like information on ground transportation in ATLANTA from the airport to the city in the morning around 9am
### 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 = 'ATLANTA' AND CITY_1.city_code = airport_service.city_code AND CITY_1.city_name = 'ATLANTA' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_0.city_code
|
### Instruction:
when did patient 013-23267's last lab test take place in 09/this year?
### 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 = '013-23267')) AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', lab.labresulttime) = '09' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
count the number of times patient 006-36108 had urine catheter output in the previous month.
### 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 = '006-36108')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'urine catheter' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
|
### Instruction:
what was the name of the organism that was found this month in the last test of the microbiology of the urine of patient 18677?
### Response:
|
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 18677) AND microbiologyevents.spec_type_desc = 'urine' AND NOT microbiologyevents.org_name IS NULL AND DATETIME(microbiologyevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY microbiologyevents.charttime DESC LIMIT 1
|
### Instruction:
what was the total urine output since 1118 days ago that patient 010-29887 had?
### 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 = '010-29887')) AND intakeoutput.celllabel = 'urine' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-1118 day')
|
### Instruction:
tell me the daily maximum respiration of patient 032-2747 until 84 days ago.
### Response:
|
SELECT MAX(vitalperiodic.respiration) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '032-2747')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-84 day') GROUP BY STRFTIME('%y-%m-%d', vitalperiodic.observationtime)
|
### Instruction:
since 70 months ago has the sao2 of patient 004-49903 been normal?
### 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-49903')) AND vitalperiodic.sao2 BETWEEN sao2_lower AND sao2_upper AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-70 month')
|
### Instruction:
User's comments grouped by post.
### Response:
|
WITH commentStats AS (SELECT COUNT(Id) AS numC, MAX(Id) AS dId, MAX(CreationDate) AS dDate, PostId FROM Comments WHERE UserId = '##UserId##' GROUP BY PostId) SELECT CASE WHEN p.PostTypeId = 1 THEN 'Q' ELSE 'A' END AS "q/a", cs.numC AS "num_cmts", cs.dDate AS Latest, cs.PostId AS "post_link", c.Text AS "last_comment" FROM commentStats AS cs INNER JOIN Comments AS c ON c.Id = cs.dId INNER JOIN Posts AS p ON p.Id = cs.PostId ORDER BY cs.dDate DESC
|
### Instruction:
was heartrate from patient 029-16737 less than 128.0 during this month?
### 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 = '029-16737')) AND vitalperiodic.heartrate < 128.0 AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
|
### Instruction:
when was first the respiration of patient 017-83061 measured since 02/10/2103?
### 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 = '017-83061')) AND NOT vitalperiodic.respiration IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) >= '2103-02-10' ORDER BY vitalperiodic.observationtime LIMIT 1
|
### Instruction:
Which of the classes are being taught by Dr. Kevin Mcgowan 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 '%Kevin Mcgowan%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
what was the name of the first intake of patient 8116 that they had today?
### Response:
|
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT inputevents_cv.itemid FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8116)) AND DATETIME(inputevents_cv.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY inputevents_cv.charttime LIMIT 1)
|
### Instruction:
In next semester what classes is Dr. Jonathan Wipplinger teaching ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Jonathan Wipplinger%' 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:
the last intake patient 010-16572 had today what was the name of that?
### 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 = '010-16572')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
are any organisms found in 12/2105 in the first other test of patient 031-3355?
### 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-3355')) AND microlab.culturesite = 'other' AND STRFTIME('%y-%m', microlab.culturetakentime) = '2105-12' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
how many hours have elapsed since the first time patient 030-52327 during their current hospital visit received a lab test for hct?
### 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 = '030-52327' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'hct' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
what was the three most frequently taken test since 6 years ago for patients with age 20s?
### 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 DATETIME(labevents.charttime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 3)
|
### Instruction:
what's last respiration value of patient 025-35599 on 03/12/2101?
### Response:
|
SELECT vitalperiodic.respiration FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-35599')) AND NOT vitalperiodic.respiration IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) = '2101-03-12' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
how much d5 1/2ns was prescribed to patient 23002 last in 10/this year?
### Response:
|
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23002) AND prescriptions.drug = 'd5 1/2ns' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '10' ORDER BY prescriptions.startdate DESC LIMIT 1
|
### Instruction:
Comment count for high-rep users by day.
### Response:
|
SELECT YEAR(c.CreationDate) * 100 + MONTH(c.CreationDate) * 100 / 12 AS YearMonth, COUNT(c.Id) AS CountOfComments FROM Comments AS c INNER JOIN Users AS u ON c.UserId = u.Id WHERE u.Reputation > '##HighRepBorder:int##' GROUP BY YEAR(c.CreationDate) * 100 + MONTH(c.CreationDate) * 100 / 12 ORDER BY YEAR(c.CreationDate) * 100 + MONTH(c.CreationDate) * 100 / 12
|
### Instruction:
Top 100 users by min(questions, answers).
### Response:
|
WITH q_and_as AS (SELECT *, CASE WHEN PostTypeId = 1 THEN 1 ELSE NULL END AS isq, CASE WHEN PostTypeId = 2 THEN 1 ELSE NULL END AS isa FROM Posts WHERE PostTypeId = 1 OR PostTypeId = 2), user_posts AS (SELECT OwnerUserId, OwnerUserId AS "user_link", SUM(isq) AS questions, SUM(isa) AS answers FROM q_and_as GROUP BY OwnerUserId) SELECT 'user_link', questions, answers, (questions + answers - ABS(answers - questions)) / 2 AS minimum FROM user_posts ORDER BY minimum DESC LIMIT 100
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.