instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
FILMVID 490 has been taught by who in the past ?
### Response:
|
SELECT DISTINCT instructor.name FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'FILMVID' AND course.number = 490 AND NOT (semester.semester = 'WN' AND semester.year = 2016)
|
### Instruction:
what time was the last time patient 006-2586 had the maximum respiration value 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 = '006-2586')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY vitalperiodic.respiration DESC, vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
calculate how many times patient 027-151154 had a enteral meds/ flush intake during this 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 = '027-151154')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'enteral meds/ flush' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
|
### Instruction:
what were the top four most common procedures for the patients in the 30s?
### 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 procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
when was patient 15945 for the last time received intake on this month/28?
### 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 = 15945)) AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', inputevents_cv.charttime) = '28' ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
what was the last systemicsystolic value patient 007-849 had since 12/27/2105?
### 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 = '007-849')) AND NOT vitalperiodic.systemicsystolic IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) >= '2105-12-27' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
Does Prof. Bradley Smith teach 475 next Winter ?
### 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 = 475 AND instructor.name LIKE '%Bradley Smith%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'Winter' AND semester.semester_id = course_offering.semester AND semester.year = 2017
|
### Instruction:
calculate patient 7112's total sump #1 volume in the previous day.
### Response:
|
SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7112)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sump #1' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
what is the maximum monthly number of people diagnosed with tetralogy of fallot since 2103?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT COUNT(DISTINCT diagnoses_icd.hadm_id) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'tetralogy of fallot') AND STRFTIME('%y', diagnoses_icd.charttime) >= '2103' GROUP BY STRFTIME('%y-%m', diagnoses_icd.charttime)) AS t1
|
### Instruction:
what was the total r chest tube output of patient 010-32430 until 1694 days ago?
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-32430')) AND intakeoutput.celllabel = 'r chest tube' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-1694 day')
|
### Instruction:
when was the first time patient 017-88691 was diagnosed with s/p thoracotomy since 5 years ago?
### 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 = '017-88691')) AND diagnosis.diagnosisname = 's/p thoracotomy' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-5 year') ORDER BY diagnosis.diagnosistime LIMIT 1
|
### Instruction:
what was the minimum monthly number of patients who had late eff accidental fall since 6 years ago?
### Response:
|
SELECT MIN(t1.c1) FROM (SELECT COUNT(DISTINCT diagnoses_icd.hadm_id) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'late eff accidental fall') AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY STRFTIME('%y-%m', diagnoses_icd.charttime)) AS t1
|
### Instruction:
what is the percentile of 3.83 in a lab test of rbc given the same age of patient 027-142451 during their current hospital encounter?
### Response:
|
SELECT DISTINCT t1.c1 FROM (SELECT lab.labresult, PERCENT_RANK() OVER (ORDER BY lab.labresult) AS c1 FROM lab WHERE lab.labname = 'rbc' AND lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age = (SELECT patient.age FROM patient WHERE patient.uniquepid = '027-142451' AND patient.hospitaldischargetime IS NULL))) AS t1 WHERE t1.labresult = 3.83
|
### Instruction:
Votes per day for users above a certain reputation.
### Response:
|
SELECT Reputation, CAST(UpVotes AS INT) / DATEDIFF(Day, CreationDate, GETDATE()) AS "Upvotes per Day", CAST(DownVotes AS INT) / DATEDIFF(Day, CreationDate, GETDATE()) AS "Downvotes per Day", (CAST(UpVotes AS INT) - CAST(DownVotes AS INT)) / DATEDIFF(Day, CreationDate, GETDATE()) AS "Score per Day" FROM Users AS U WHERE U.Reputation > '##MinReputation:int?125##' AND U.Reputation < '##MaxRep:int?99999999999##' ORDER BY Reputation DESC
|
### Instruction:
patient 81461 had been diagnosed with a mitral/aortic val insuff since 1 year ago?
### 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 = 'mitral/aortic val insuff') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 81461) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year')
|
### Instruction:
how many days has elapsed since the first time during the current hospital visit patient 027-203413 had received a pt - inr lab test?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', lab.labresulttime)) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-203413' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'pt - inr' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
what are the four most frequently ordered procedures for patients with ages 40s?
### 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 procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 40 AND 49) GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
how many days has passed since the last time patient 007-16517 got a alkaline phos. lab test during this hospital visit?
### 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 = '007-16517' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'alkaline phos.' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
what's the first value of the arterial bp [diastolic] of patient 4269?
### 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 = 4269)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
did patient 010-16627 underwent antibiotics - quinolone in another hospital since 2105?
### Response:
|
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '010-16627' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '010-16627' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'antibiotics - quinolone' AND STRFTIME('%y', treatment.treatmenttime) >= '2105'
|
### Instruction:
how many days has it been since patient 006-124193's first bedside glucose lab test during their 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-124193' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'bedside glucose' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
when did patient 005-12192 first receive a prescription for calcium gluconate 100 mg/ml (10 %) iv : 10 ml?
### Response:
|
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-12192')) AND medication.drugname = 'calcium gluconate 100 mg/ml (10 %) iv : 10 ml' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
tell me the monthly average heartrate of patient 006-188114 until 92 days ago.
### Response:
|
SELECT AVG(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 = '006-188114')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-92 day') GROUP BY STRFTIME('%y-%m', vitalperiodic.observationtime)
|
### Instruction:
what is the number of hours passed since patient 010-21105 had a last mri - head in this hospital visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-21105' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'mri - head' ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
i would like to know the yearly average sao2 of patient 007-16517 since 1 month ago.
### Response:
|
SELECT AVG(vitalperiodic.sao2) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-16517')) AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-1 month') GROUP BY STRFTIME('%y', vitalperiodic.observationtime)
|
### Instruction:
How effective is the tour?.
### Response:
|
SELECT Posts.Score AS Score, SUM(CASE WHEN Posts.CreationDate <= COALESCE(Badges.Date, CURRENT_TIMESTAMP()) THEN 1 ELSE 0 END) AS TouredFirst, SUM(CASE WHEN Posts.CreationDate > COALESCE(Badges.Date, CURRENT_TIMESTAMP()) THEN 1 ELSE 0 END) AS TouredLater FROM Posts INNER JOIN Users ON Posts.OwnerUserId = Users.Id LEFT JOIN Badges ON Badges.UserId = Users.Id WHERE Badges.Name = 'Informed' AND Posts.Score < 20 AND Posts.Score >= -10 GROUP BY Posts.Score ORDER BY Posts.Score
|
### Instruction:
when was the first sao2 of patient 006-161415 measured on 10/27/2102?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-161415')) AND NOT vitalperiodic.sao2 IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) = '2102-10-27' ORDER BY vitalperiodic.observationtime LIMIT 1
|
### Instruction:
when did patient 016-1459 last receive an atrial flutter - 1:1 conduction diagnosis during their first 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 = '016-1459' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND diagnosis.diagnosisname = 'atrial flutter - 1:1 conduction' ORDER BY diagnosis.diagnosistime DESC LIMIT 1
|
### Instruction:
how much is patient 62983's total stool out ileostomy output on the first icu visit?
### 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 = 62983) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'stool out ileostomy' AND d_items.linksto = 'outputevents')
|
### Instruction:
Please provide me with a list of classes being taught by Dr. Celia Cunningham 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 '%Celia Cunningham%' 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:
in this month, when was the last time that patient 030-34260 was prescribed with a medication via po route?
### 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 = '030-34260')) AND medication.routeadmin = 'po' AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
tell me the last time that patient 031-1337 has been diagnosed with obstructive sleep apnea since 1 year ago?
### 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 = '031-1337')) AND diagnosis.diagnosisname = 'obstructive sleep apnea' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY diagnosis.diagnosistime DESC LIMIT 1
|
### Instruction:
what was the last hemoglobin in patient 64881 in 03/last year?
### Response:
|
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 64881) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'hemoglobin') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', labevents.charttime) = '03' ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
had any volume (ml) fentanyl been given to patient 021-32860 since 05/2104?
### 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 = '021-32860')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'volume (ml) fentanyl' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) >= '2104-05'
|
### Instruction:
User Rentention: Year-over-Year User Activity based on Join Date [sql pivot query]. Looks at only/all Posts including deleted to determine annual activity. (Click TAB#2 for detail.)
User Retention: How many years have users kept coming back after the year they joined?
Also demonstrates multiple T-SQL Dynamic Crosstab/Pivot Table techniques (aka SQL Cross-tab query example)
Related: Query# 884709
### Response:
|
SELECT DISTINCT YEAR(CreationDate) AS "year", OwnerUserId FROM Posts WHERE CreationDate >= DATEADD(year, -1, GETDATE()) AND OwnerUserId > 0 ORDER BY YEAR(CreationDate), OwnerUserId
|
### Instruction:
Next semester is Prof. Lauren Benjamin teaching 453 ?
### 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 = 453 AND instructor.name LIKE '%Lauren Benjamin%' 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 first magnesium lab test time in 10/this year for patient 22120?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'magnesium') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22120) AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', labevents.charttime) = '10' ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
Users (with minimum rep) ranked by Median Post Score. Under construction
### Response:
|
SELECT OwnerUserId AS "user_link", AVG(Score) AS MedianScore FROM (SELECT OwnerUserId, Score, ROW_NUMBER() OVER (PARTITION BY OwnerUserId ORDER BY Score) AS RowAsc, ROW_NUMBER() OVER (PARTITION BY OwnerUserId ORDER BY Score DESC) AS RowDesc FROM Posts INNER JOIN Users ON Users.Id = OwnerUserId WHERE Users.Reputation >= '##MinReputation##' AND Posts.PostTypeId = 2) AS x WHERE RowAsc IN (RowDesc, RowDesc - 1, RowDesc + 1) GROUP BY OwnerUserId ORDER BY MedianScore DESC
|
### Instruction:
what is the total amount of input that patient 19096 on 07/06/this year has received?
### 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 = 19096)) AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', inputevents_cv.charttime) = '07-06'
|
### Instruction:
did patient 73713 excreted any oral gastric last month?
### 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 = 73713)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'oral gastric' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
|
### Instruction:
what was the last time patient 006-195316 received a prescription for trazodone, since 09/2105?
### 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 = '006-195316')) AND medication.drugname = 'trazodone' AND STRFTIME('%y-%m', medication.drugstarttime) >= '2105-09' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
how many patients this year had an intake of normal saline_gu?
### 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 = 'normal saline_gu' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')))
|
### Instruction:
has patient 028-62326 had any volume (ml) epinephrine intake until 11/2105.
### 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 = '028-62326')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'volume (ml) epinephrine' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) <= '2105-11'
|
### Instruction:
AWS Questions: Time until Answer.
### Response:
|
SELECT Question.Id, MIN(Question.CreationDate) AS Question_date, MIN(Answer.CreationDate) AS Answer_date FROM Posts AS Question LEFT OUTER JOIN Posts AS Answer ON Question.Id = Answer.ParentId WHERE Question.PostTypeId = 1 AND Question.ClosedDate IS NULL AND (Question.Tags LIKE '%<amazon-%' OR Question.Tags LIKE '%<aws-%') AND Question.CreationDate >= '2020-01-01' AND Question.CreationDate != Answer.CreationDate AND (Answer.OwnerUserId IS NULL OR Question.OwnerUserId != Answer.OwnerUserId) AND Answer.CreationDate IS NULL GROUP BY Question.Id LIMIT 10
|
### Instruction:
when is the first time that patient 002-52932 has had a heartrate measured until 03/10/2100?
### 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-52932')) AND NOT vitalperiodic.heartrate IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) <= '2100-03-10' ORDER BY vitalperiodic.observationtime LIMIT 1
|
### Instruction:
Who was the past teacher for CMBIOL 685 ?
### 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 = 'CMBIOL' AND course.number = 685 AND NOT (semester.semester = 'WN' AND semester.year = 2016)
|
### Instruction:
what was the last time that patient 004-60828 had a maximum respiration until 757 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 = '004-60828')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-757 day') ORDER BY vitalperiodic.respiration DESC, vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
what was the first thing patient 016-16960 received for intake on 05/23/2102?
### 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 = '016-16960')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2102-05-23' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
What 's the name of the Undergraduate South and Southeast Asian Culture teacher next Winter ?
### 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 semester ON semester.semester_id = course_offering.semester INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.name LIKE '%Undergraduate South and Southeast Asian Culture%' AND semester.semester = 'Winter' AND semester.year = 2017
|
### Instruction:
give the total amount of crystalloids given to patient 013-12480 until 338 days ago.
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-12480')) AND intakeoutput.celllabel = 'crystalloids' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-338 day')
|
### Instruction:
For End of Fiscal Years past 1980 that also have as % of GDP Low-High of 83.4-84.4, and a Debt Held By Public ($Billions) smaller than 7,552 what would be the average Gross Debt in $Billions undeflated Treas. in said years?
### Response:
|
SELECT AVG("Gross Debt in $Billions undeflated Treas.") FROM table_54105 WHERE "End of Fiscal Year" > '1980' AND "as % of GDP Low-High" = '83.4-84.4' AND "Debt Held By Public ($Billions)" < '7,552'
|
### Instruction:
how many times did patient 56490 had received a entral infus nutrit sub during this year?
### Response:
|
SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'entral infus nutrit sub') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 56490) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
Voting and History Event timeline to your posts.
### Response:
|
SELECT Posts.Id AS "post_link", PostTypes.Name AS PostType, 'Vote' AS EventType, VoteTypes.Name AS VoteType, Votes.CreationDate AS VoteDate, Votes.UserId AS "user_link", Votes.BountyAmount FROM Votes, VoteTypes, Posts, Users, PostTypes WHERE Votes.VoteTypeId = VoteTypes.Id AND Votes.PostId = Posts.Id AND Posts.OwnerUserId = Users.Id AND Users.AccountId = '##SEAccountId:int##' AND Posts.PostTypeId = PostTypes.Id ORDER BY Votes.CreationDate DESC, Votes.Id DESC
|
### Instruction:
in their current hospital encounter how many hours has it been since when patient 012-31752 received a glucose lab test for the last time?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', lab.labresulttime)) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-31752' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'glucose' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
what is the monthly average amount of urinary osmolality of patient 013-9305 the last 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 = '013-9305')) AND lab.labname = 'urinary osmolality' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY STRFTIME('%y-%m', lab.labresulttime)
|
### Instruction:
what was patient 009-12221's sao2 for the first time since 05/23/2101?
### Response:
|
SELECT vitalperiodic.sao2 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-12221')) AND NOT vitalperiodic.sao2 IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) >= '2101-05-23' ORDER BY vitalperiodic.observationtime LIMIT 1
|
### Instruction:
Distribution of the number of review actions on close review tasks that were invalidated.
### Response:
|
SELECT COALESCE(total, 0) AS "# Of Review Actions", COUNT(t.Id) AS "Count", COUNT(t.Id) * 100.0 / SUM(COUNT(*)) OVER () AS "Percent" FROM ReviewTasks AS t LEFT OUTER JOIN (SELECT COUNT(r.ReviewTaskId) AS total, r.ReviewTaskId FROM ReviewTaskResults AS r GROUP BY r.ReviewTaskId) AS counts ON t.Id = counts.ReviewTaskId WHERE t.ReviewTaskTypeId = 2 AND t.ReviewTaskStateId = 3 AND t.CreationDate > @epoch GROUP BY total ORDER BY '# Of Review Actions'
|
### Instruction:
what was the name of the drug that was prescribed last to patient 021-111547 since 20 months ago via deepsubcut 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 = '021-111547')) AND medication.routeadmin = 'deepsubcut' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-20 month') ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
have patient 1862 had any d5w intake until 53 months ago?
### 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 = 1862)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd5w' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) <= DATETIME(CURRENT_TIME(), '-53 month')
|
### Instruction:
tell me the yearly minimum heartrate of patient 033-12085 until 1738 days ago.
### Response:
|
SELECT MIN(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 = '033-12085')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-1738 day') GROUP BY STRFTIME('%y', vitalperiodic.observationtime)
|
### Instruction:
what is the average number of patients diagnosed with acute lung edema nos monthly since 2100?
### 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 = 'acute lung edema nos') AND STRFTIME('%y', diagnoses_icd.charttime) >= '2100' GROUP BY STRFTIME('%y-%m', diagnoses_icd.charttime)) AS t1
|
### Instruction:
when did patient 003-34282 first receive prescriptions for insulin lispro, recombinant in their last hospital encounter?
### 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 = '003-34282' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND medication.drugname = 'insulin lispro, recombinant' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
this year patient 16088 had undergone any venous cath 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 = 'venous cath nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 16088) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
did patient 13528 have osteoarthros nos-unspec diagnosed since 2 years ago?
### 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 = 'osteoarthros nos-unspec') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13528) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-2 year')
|
### Instruction:
on the current icu visit when was the last chest tube output: pleural anterior output time for patient 016-18575?
### 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 = '016-18575') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'chest tube output: pleural anterior' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name.
### Response:
|
SELECT T1.company_id, T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Engineers AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id HAVING COUNT(*) >= 2 UNION SELECT T3.company_id, T3.company_name FROM Third_Party_Companies AS T3 JOIN Maintenance_Contracts AS T4 ON T3.company_id = T4.maintenance_contract_company_id GROUP BY T3.company_id HAVING COUNT(*) >= 2
|
### Instruction:
tell me the daily minimum respiration of patient 010-15363 since 62 months ago.
### Response:
|
SELECT MIN(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 = '010-15363')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-62 month') GROUP BY STRFTIME('%y-%m-%d', vitalperiodic.observationtime)
|
### Instruction:
JavaScript (and not ES6) related.
### Response:
|
SELECT *, COUNT(*) AS count, DAY(LAST_DATE_OF_MONTH(month)) AS DaysInMonth FROM (SELECT DATE(CAST(TIME_TO_STR(CreationDate, '%Y') AS TEXT) + '-' + CAST(TIME_TO_STR(CreationDate, '%m') AS TEXT) + '-01') AS month FROM Posts WHERE Tags LIKE '%javascript%' AND NOT Tags LIKE '%ecmascript-6%' AND NOT Tags LIKE '%ecmascript-2015%' AND NOT Tags LIKE '%ecmascript-harmony%' AND NOT Tags LIKE '%es6%' AND CreationDate >= '20110401') AS X GROUP BY month ORDER BY month
|
### Instruction:
User Stats for Voting: Upvotes, Downvotes, Reputation & TotalPosts.
### Response:
|
SELECT u.Id, u.Reputation, u.DisplayName, u.UpVotes, u.DownVotes, Q.TotalQs, A.TotalAs FROM Users AS u LEFT JOIN (SELECT COUNT(OwnerUserId) AS TotalQs, OwnerUserId FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId) AS Q ON u.Id = Q.OwnerUserId LEFT JOIN (SELECT COUNT(OwnerUserId) AS TotalAs, OwnerUserId FROM Posts WHERE PostTypeId = 2 GROUP BY OwnerUserId) AS A ON u.Id = A.OwnerUserId WHERE u.Id IN ('##UserId##')
|
### Instruction:
when was last time patient 028-22327 was diagnosed since 4 years ago with cardiomyopathy?
### 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 = '028-22327')) AND diagnosis.diagnosisname = 'cardiomyopathy' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-4 year') ORDER BY diagnosis.diagnosistime DESC LIMIT 1
|
### Instruction:
what was the medication patient 006-123134 was prescribed for the first time during this month via the po 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 = '006-123134')) AND medication.routeadmin = 'po' AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
Beginning next semester ; which classes will be taught by Dr. Giorgio Bertellini ?
### 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 '%Giorgio Bertellini%' 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:
Find the name of dorms which have both TV Lounge and Study Room as amenities.
### 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' INTERSECT 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:
Past Bountied Questions for a Given Tag.
### Response:
|
SELECT v.PostId AS "post_link", v.CreationDate AS "bounty_date", v.BountyAmount AS "bounty_amount", v.UserId AS "bounty_giver", p.Tags AS "tags", p.CreationDate AS "question_date" FROM Votes AS v INNER JOIN PostTags AS pt ON pt.PostId = v.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id AND t.TagName = '##TagName:string##' INNER JOIN Posts AS p ON p.Id = pt.PostId AND p.PostTypeId = 1 WHERE v.VoteTypeId = 8 ORDER BY v.CreationDate DESC
|
### Instruction:
What number of PHIL 427 prerequisites have I fulfilled ?
### Response:
|
SELECT COUNT(DISTINCT COURSE_1.department, COURSE_0.number) FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite, student_record WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'PHIL' AND COURSE_1.number = 427 AND student_record.course_id = COURSE_0.course_id AND student_record.student_id = 1
|
### Instruction:
what was the first protein-calorie malnutrition diagnosis time of patient 008-22202 in their first 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 = '008-22202' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND diagnosis.diagnosisname = 'protein-calorie malnutrition' ORDER BY diagnosis.diagnosistime LIMIT 1
|
### Instruction:
what is the daily maximum of the weight of patient 016-18575 in 12/this year?
### Response:
|
SELECT MAX(patient.admissionweight) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-18575') AND NOT patient.admissionweight IS NULL AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', patient.unitadmittime) = '12' GROUP BY STRFTIME('%y-%m-%d', patient.unitadmittime)
|
### Instruction:
what was the name of the procedure that was given two or more times to patient 58730?
### 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, COUNT(procedures_icd.charttime) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 58730) GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 >= 2)
|
### Instruction:
When will 794 and 345 be over if I need to get to work on time before 5:00 P.M. .
### Response:
|
SELECT DISTINCT course_offering.end_time, course.number FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'department0' AND (course.number = 794 OR course.number = 345) AND course_offering.end_time < '17:00:00' AND semester.semester = 'WN' AND semester.year = 2016
|
### Instruction:
how many days has passed since patient 015-23047 first received the foley catheter on the current hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-23047' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'foley catheter' ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
Which teacher will teach Lyric , Elegy , and Iambus this semester ?
### 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.name LIKE '%Lyric , Elegy , and Iambus%' AND semester.semester = 'WN' AND semester.year = 2016
|
### Instruction:
Which are the classes that Dr. Megan Berkobien teaches 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 '%Megan Berkobien%' 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:
calculate the number of times patient 14836 had a chest tube #1 since 506 days ago.
### Response:
|
SELECT COUNT(*) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14836)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'chest tube #1' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime) >= DATETIME(CURRENT_TIME(), '-506 day')
|
### Instruction:
what was the name of that output that patient 002-4486 last had on 03/06/2105?
### 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 = '002-4486')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2105-03-06' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
Lucretius and Roman Epicureanism next Winter is being taught by who ?
### 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 semester ON semester.semester_id = course_offering.semester INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.name LIKE '%Lucretius and Roman Epicureanism%' AND semester.semester = 'Winter' AND semester.year = 2017
|
### Instruction:
how did patient 4469's total right jp output come out since 1766 days ago?
### 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 = 4469)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'right jp' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime) >= DATETIME(CURRENT_TIME(), '-1766 day')
|
### Instruction:
what was patient 025-30850's last intake since 02/17/2104.
### 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 = '025-30850')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2104-02-17' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
count the number of people who have had a coronar arteriogr-2 cath 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 = 'coronar arteriogr-2 cath') AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
|
### Instruction:
when on last month/05 patient 5142 had an intake for the last time?
### 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) = '05' ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
MUSTHTRE 133 will be taught by who next semester ?
### 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 = 'MUSTHTRE' AND course.number = 133 AND semester.semester = 'FA' AND semester.year = 2016
|
### Instruction:
tell me the four most common medical diagnoses in a year before?
### 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, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
was the fluticasone-salmeterol 250-50 mcg/dose in aepb prescribed to patient 035-2205 on their current hospital encounter?
### 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-2205' AND patient.hospitaldischargetime IS NULL)) AND medication.drugname = 'fluticasone-salmeterol 250-50 mcg/dose in aepb'
|
### Instruction:
has patient 030-8973 had any enteral osmolte 1.5 intake since 66 months ago.
### 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 = '030-8973')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'enteral osmolte 1.5' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-66 month')
|
### Instruction:
when did patient 015-52724 first had the maximum platelets x 1000 level 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 = '015-52724')) AND lab.labname = 'platelets x 1000' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY lab.labresult DESC, lab.labresulttime LIMIT 1
|
### Instruction:
has patient 030-3247 had a lab test in 03/last year for troponin - i?
### Response:
|
SELECT COUNT(*) > 0 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-3247')) AND lab.labname = 'troponin - i' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', lab.labresulttime) = '03'
|
### Instruction:
how much does the average hospital cost including a procedure called cnt intraart bld gas mon in 2101?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'cnt intraart bld gas mon')) AND STRFTIME('%y', cost.chargetime) = '2101' GROUP BY cost.hadm_id) AS t1
|
### Instruction:
Select Top Users from India who have answered a given tag.
### Response:
|
SELECT u.Id, u.DisplayName, u.Reputation, u.Location, COUNT(*) AS PostCount FROM Users AS u INNER JOIN Posts AS p ON u.Id = p.OwnerUserId INNER JOIN Posts AS q ON p.ParentId = q.Id INNER JOIN PostTags AS pt ON q.Id = pt.PostId WHERE u.Reputation > 5000 AND u.Location LIKE '%India' AND p.PostTypeId = 2 AND (pt.TagId = 58838 OR pt.TagId = 154) GROUP BY u.Id, u.DisplayName, u.Reputation, u.Location ORDER BY PostCount DESC LIMIT 1000
|
### Instruction:
how many times does patient 015-20584 produce hemovac #1 since 03/30/2102?
### 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 = '015-20584')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'hemovac #1' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2102-03-30'
|
### Instruction:
how many times did patient 95280 had received a inser temp pacemaker sys last year?
### Response:
|
SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'inser temp pacemaker sys') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 95280) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
Next semester , who teaches INTLSTD 370 ?
### 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 = 'INTLSTD' AND course.number = 370 AND semester.semester = 'FA' AND semester.year = 2016
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.