instruction
stringlengths 53
549
| output
stringlengths 30
2.33k
|
---|---|
### Instruction:
how many days elapsed since patient 013-11660 received his bedside glucose lab test for the last 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 = '013-11660' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'bedside glucose' ORDER BY lab.labresulttime DESC LIMIT 1 |
### Instruction:
how many days have passed since the first time patient 027-136480 received a lab test of alt (sgpt) during the current 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 = '027-136480' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'alt (sgpt)' ORDER BY lab.labresulttime LIMIT 1 |
### Instruction:
in 03/last year what was the last value of a base excess lab test of patient 42211?
### Response:
| SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 42211) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'base excess') 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:
the first time patient 67902 received int inser lead atri-vent until 2104?
### Response:
| SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'int inser lead atri-vent') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 67902) AND STRFTIME('%y', procedures_icd.charttime) <= '2104' ORDER BY procedures_icd.charttime LIMIT 1 |
### Instruction:
How much reputation are you getting from your past work?. Take the 'unexpected' reputation coming from your answers from last month.
Suppose now you constantly get those, and figure out how much rep per day you are getting for your past work without 'working for it' on that given day
### Response:
| SELECT Users.Id, usersAnswers.Answers, Users.Reputation, (Users.Reputation / UsersAnswers.Answers) AS Ratio FROM (SELECT U.Id, COUNT(Posts.Id) AS Answers FROM Posts, Users AS U WHERE Posts.OwnerUserId = U.Id AND Posts.PostTypeId = 2 GROUP BY U.Id) AS UsersAnswers, Users WHERE UsersAnswers.Id = Users.Id ORDER BY Ratio DESC |
### Instruction:
Users 'ranking' by sign up date and activity.
### Response:
| SELECT u.Id AS "id", u.Id AS "user_link", u.Reputation, MIN(u.CreationDate) AS "user_creation_date", MIN(DATEDIFF(dd, u.CreationDate, GETDATE())) - 7 AS "days_passed_since", MIN(p.CreationDate) AS "last_activity_date", MIN(DATEDIFF(dd, p.CreationDate, GETDATE())) - 7 AS "days_passed_since" FROM Users AS u INNER JOIN Posts AS p ON p.OwnerUserId = u.Id WHERE u.Id != -1 GROUP BY u.Id, u.Reputation ORDER BY Reputation DESC |
### 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:
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:
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:
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:
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 |
### 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:
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:
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:
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:
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:
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:
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:
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:
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:
No Thanks III: The Revenge.
### Response:
| SELECT Id AS "post_link", Body FROM Posts WHERE LOWER(Body) LIKE '%regards%' OR LOWER(Body) LIKE '%greetings%' OR LOWER(Body) LIKE '%tanks in%' OR LOWER(Body) LIKE '%i need%help%' OR LOWER(Body) LIKE '%i need%halp%' OR LOWER(Body) LIKE '%hi %' OR LOWER(Body) LIKE 'guys%' OR LOWER(Body) LIKE '%hello%' OR LOWER(Body) LIKE '%good morning%' OR LOWER(Body) LIKE '%good day%' OR LOWER(Body) LIKE '%good afternoon%' LIMIT 1000 |
### Instruction:
Overall site activity per hour.
### Response:
| SELECT h.hours AS "hour", COUNT(postsCounter) AS "posts" FROM (SELECT TIME_TO_STR(CreationDate, '%h') AS active, 1 AS counter, 1 AS postsCounter, NULL AS commentsCounter, NULL AS editsCounter, NULL AS suggestedCounter FROM Votes WHERE VoteTypeId = 1 AND TIME_TO_STR(CreationDate, '%Y') >= 2013) AS a RIGHT JOIN (SELECT DISTINCT TIME_TO_STR(CreationDate, '%h') AS hours FROM Votes WHERE VoteTypeId = 1) AS h ON a.active = h.hours GROUP BY h.hours ORDER BY h.hours |
### Instruction:
what is the yearly average of the weight of patient 17237?
### Response:
| SELECT AVG(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17237)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit wt' AND d_items.linksto = 'chartevents') GROUP BY STRFTIME('%y', chartevents.charttime) |
### Instruction:
Top users in Sri Lanka in Scala.
### Response:
| SELECT ROW_NUMBER() OVER (ORDER BY U.Reputation DESC, U.Age) AS "#", U.Id AS "user_link", U.Age, U.Location, U.Reputation, U.UpVotes, U.DownVotes FROM Users AS U WHERE U.Id IN (SELECT DISTINCT U.Id FROM Users AS U INNER JOIN Posts AS P ON U.Id = P.OwnerUserId INNER JOIN PostTags AS PT ON PT.PostId = P.Id INNER JOIN Tags AS T ON T.Id = PT.TagId WHERE LOWER(U.Location) LIKE '%sri lanka%' AND LOWER(T.TagName) LIKE 'scala%') |
### Instruction:
Most common tags with missing wiki and excerpt. Lists the most commonly used tags with empty/missing tag wikis (wiki AND excerpt).
### Response:
| SELECT Count, ('site://tags/' + TagName + '|' + TagName) AS TagName, ExcerptPostId AS "post_link", WikiPostId AS "post_link" FROM Tags AS t LEFT JOIN Posts AS pe ON pe.Id = t.ExcerptPostId LEFT JOIN Posts AS pw ON pw.Id = t.WikiPostId WHERE ExcerptPostId IS NULL AND WikiPostId IS NULL OR LENGTH(pe.Body) = 0 OR LENGTH(pw.Body) = 0 ORDER BY Count DESC |
### Instruction:
tell me the minimum cost of a hospital that involved pancreatitis - relapsing last year?
### Response:
| SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'pancreatitis - relapsing')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1 |
### Instruction:
is since 1 year ago patient 42473 diagnosed with hx of past noncompliance?
### 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 = 'hx of past noncompliance') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 42473) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') |
### Instruction:
what is the number of times that patient 76327 had had foley today?
### 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 = 76327)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'foley' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') |
### Instruction:
What are the 100 -level courses in Fall and Winter , if there are any ?
### Response:
| SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course, course_offering, semester WHERE ((semester.semester = 'FA' AND semester.year = 2016) OR (semester.semester = 'WN' AND semester.year = 2017)) AND course.course_id = course_offering.course_id AND course.department = 'department0' AND course.number BETWEEN 100 AND 100 + 100 AND semester.semester_id = course_offering.semester |
### Instruction:
tell me the total dose of prismasate (b22 k4) prescribed to patient 3403 in 07/this year?
### Response:
| SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3403) AND prescriptions.drug = 'prismasate (b22 k4)' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '07' |
### Instruction:
when was patient 010-16572's systemicdiastolic measured for the first time until 1 day 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 = '010-16572')) AND NOT vitalperiodic.systemicdiastolic IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-1 day') ORDER BY vitalperiodic.observationtime LIMIT 1 |
### Instruction:
Question by user A answered by user B.
### Response:
| SELECT q.Id AS "post_link", q.OwnerUserId AS "user_link", q.Score AS "Q Score", a.Id AS "post_link", a.OwnerUserId AS "user_link", a.Score AS "A Score", CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END AS "Accepted?" FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id WHERE q.PostTypeId = 1 AND a.PostTypeId = 2 AND q.OwnerUserId = '##questUserID##' AND a.OwnerUserId = '##answerUserId##' ORDER BY q.CreationDate |
### Instruction:
did patient 002-3736's respiration ever greater than 24.0 a month before.
### Response:
| SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-3736')) AND vitalperiodic.respiration > 24.0 AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') |
### Instruction:
what was the name of the intake that patient 017-83061 until 943 days ago last had?
### 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 = '017-83061')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-943 day') ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1 |
### Instruction:
what was patient 006-81423's first diagnosis of acute renal failure time in the last hospital encounter?
### Response:
| SELECT diagnosis.diagnosistime FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-81423' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND diagnosis.diagnosisname = 'acute renal failure' ORDER BY diagnosis.diagnosistime LIMIT 1 |
### Instruction:
Questions and Answers per month.
### Response:
| SELECT DATEADD(month, DATEDIFF(month, @start, CreationDate), @start) AS "month", SUM(CASE WHEN PostTypeId = 1 THEN 1 ELSE 0 END) AS "questions", SUM(CASE WHEN PostTypeId = 2 THEN 1 ELSE 0 END) AS "answers" FROM Posts WHERE (PostTypeId = 1 OR PostTypeId = 2) AND CreationDate >= @start AND CreationDate < @stop AND Score = 0 GROUP BY DATEADD(month, DATEDIFF(month, @start, CreationDate), @start) ORDER BY DATEADD(month, DATEDIFF(month, @start, CreationDate), @start) |
### Instruction:
when is the first time patient 006-254182 was prescribed a medication via inpl route until 15 months ago?
### 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-254182')) AND medication.routeadmin = 'inpl' AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-15 month') ORDER BY medication.drugstarttime LIMIT 1 |
### Instruction:
What are the class numbers Dr. Tessa Brown is doing in the 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 '%Tessa Brown%' 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:
is the arterial bp mean of patient 5849 normal?
### Response:
| SELECT COUNT(*) > 0 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 = 5849)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND chartevents.valuenum BETWEEN mean_bp_lower AND mean_bp_upper |
### Instruction:
has patient 032-18678's respiration been less today than 21.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 = '032-18678')) AND vitalperiodic.respiration < 21.0 AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') |
### Instruction:
what is the average value of ptt in patient 55503's body in 11/last year?
### Response:
| SELECT AVG(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 55503) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'ptt') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', labevents.charttime) = '11' |
### Instruction:
what has been the total amount of input patient 006-200601 received on 09/20/2104?
### Response:
| SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-200601')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2104-09-20' |
### Instruction:
what is the first procedure that patient 95088 received during the previous 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 = 95088) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY procedures_icd.charttime LIMIT 1) |
### Instruction:
Are there any courses being taught by Dr. Pedro Sanchez 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 '%Pedro Sanchez%' 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 my accepted answer percentage rate?. What is my accepted answer percentage rate
On avg how often are answers I give, accepted.
----
Original source: https://data.stackexchange.com/stackoverflow/query/949/what-is-my-accepted-answer-percentage-rate
### Response:
| SELECT (CAST(COUNT(a.Id) AS FLOAT) / (SELECT COUNT(*) FROM Posts WHERE OwnerUserId = @UserId AND PostTypeId = 2) * 100) AS AcceptedPercentage FROM Posts AS q INNER JOIN Posts AS a ON q.AcceptedAnswerId = a.Id WHERE a.OwnerUserId = @UserId AND a.PostTypeId = 2 |
### Instruction:
what is the maximum total cost for the hospital involving a procedure called valve replacement or repair - routine during the last year?
### Response:
| SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'valve replacement or repair - routine')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1 |
### Instruction:
what is the monthly maximum value of patient 027-168760's urinary creatinine on their first hospital visit?
### 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 = '027-168760' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'urinary creatinine' GROUP BY STRFTIME('%y-%m', lab.labresulttime) |
### Instruction:
what was the name of the output the last time patient 51177 had since 08/01/2101?
### Response:
| SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT outputevents.itemid FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 51177)) AND STRFTIME('%y-%m-%d', outputevents.charttime) >= '2101-08-01' ORDER BY outputevents.charttime DESC LIMIT 1) |
### Instruction:
DENTHYG 220 had who for GSIs last semester ?
### Response:
| SELECT DISTINCT student.firstname, student.lastname FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN gsi ON gsi.course_offering_id = course_offering.offering_id INNER JOIN student ON student.student_id = gsi.student_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'DENTHYG' AND course.number = 220 AND semester.semester = 'FA' AND semester.year = 2015 |
### Instruction:
number of posts per day of week over the years.
### Response:
| SELECT COUNT(*) AS "all", SUM(CASE WHEN CreationDate BETWEEN DATEADD(yy, -1, GETDATE()) AND GETDATE() THEN 1 ELSE 0 END) AS "year", SUM(CASE WHEN CreationDate BETWEEN DATEADD(m, -1, GETDATE()) AND GETDATE() THEN 1 ELSE 0 END) AS "month", SUM(CASE WHEN CreationDate BETWEEN DATEADD(wk, -1, GETDATE()) AND GETDATE() THEN 1 ELSE 0 END) AS "week", DATEPART(dw, CreationDate) AS "day_of_week" FROM Posts GROUP BY DATEPART(dw, CreationDate) |
### Instruction:
Usuarios con 10 o m s preguntas sin aceptar.
### Response:
| SELECT U.Id, U.DisplayName, COUNT(CASE WHEN P.AcceptedAnswerId IS NULL THEN 1 ELSE NULL END) AS PreguntasSinAceptar, COUNT(CASE WHEN NOT P.AcceptedAnswerId IS NULL THEN 1 ELSE NULL END) AS PreguntasAceptadas FROM Users AS U INNER JOIN Posts AS P ON U.Id = P.OwnerUserId WHERE P.PostTypeId = 1 AND P.AnswerCount > 0 GROUP BY U.Id, U.DisplayName HAVING COUNT(CASE WHEN P.AcceptedAnswerId IS NULL THEN 1 ELSE NULL END) >= 10 ORDER BY 3 DESC |
### Instruction:
get number answers after time t.
### Response:
| SELECT QuestionPost.Id, SUM(CASE WHEN AnsweringPostWithinInterval.Id IS NULL THEN 0 ELSE 1 END) AS num_answering_after_t FROM Posts AS QuestionPost LEFT JOIN Posts AS AnsweringPostWithinInterval ON AnsweringPostWithinInterval.ParentId = QuestionPost.Id AND AnsweringPostWithinInterval.CreationDate > DATEADD(dd, 1, QuestionPost.CreationDate) AND AnsweringPostWithinInterval.ClosedDate IS NULL WHERE QuestionPost.PostTypeId = (SELECT Id FROM PostTypes WHERE Name = 'Question') AND QuestionPost.ClosedDate IS NULL AND QuestionPost.Id % 158 = 0 GROUP BY QuestionPost.Id |
### Instruction:
Are there sections of POLSCI 383 that are offered after 11:30 P.M. ?
### Response:
| SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '11:30' AND course.course_id = course_offering.course_id AND course.department = 'POLSCI' AND course.number = 383 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
Votes before and after entry on the HNQ list.
### Response:
| SELECT CASE WHEN v.CreationDate < ph.CreationDate THEN 'pre' ELSE 'post' END AS epoch, vt.Name, COUNT(*) AS votes FROM PostHistory AS ph JOIN Posts AS p ON ph.PostId = COALESCE(p.ParentId, p.Id) JOIN Votes AS v ON v.PostId = p.Id JOIN VoteTypes AS vt ON VoteTypeId = vt.Id WHERE PostHistoryTypeId IN (52) GROUP BY CASE WHEN v.CreationDate < ph.CreationDate THEN 'pre' ELSE 'post' END, vt.Name, vt.Id ORDER BY vt.Id, epoch DESC |
### Instruction:
did patient 12410 excreted any urine out foley on the last icu visit?
### 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 = 12410) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'urine out foley' AND d_items.linksto = 'outputevents') |
### Instruction:
what was the name of the last intake that patient 739 yesterday had?
### 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 = 739)) AND DATETIME(inputevents_cv.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY inputevents_cv.charttime DESC LIMIT 1) |
### Instruction:
what are the fares for flights between ATLANTA and DFW provided by AA
### Response:
| SELECT DISTINCT fare.fare_id FROM airport, airport_service, city, fare, flight, flight_fare WHERE (airport.airport_code = 'DFW' AND city.city_code = airport_service.city_code AND city.city_name = 'ATLANTA' AND flight.from_airport = airport_service.airport_code AND flight.to_airport = airport.airport_code) AND flight_fare.fare_id = fare.fare_id AND flight.airline_code = 'AA' AND flight.flight_id = flight_fare.flight_id |
### Instruction:
when was the last time patient 021-25705 has been diagnosed with depression since 2 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 = '021-25705')) AND diagnosis.diagnosisname = 'depression' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-2 year') ORDER BY diagnosis.diagnosistime DESC LIMIT 1 |
### Instruction:
Users Answer and Question Votes. See the total up and down votes for answers and questions for a given user.
### Response:
| SELECT (CASE WHEN p.PostTypeId = 1 THEN 'Question' WHEN p.PostTypeId = 2 THEN 'Answer' END) AS "post_type", (CASE WHEN v.VoteTypeId = 2 THEN 'Up Vote' WHEN v.VoteTypeId = 3 THEN 'Down Vote' END) AS "vote_type", COUNT(*) AS Votes FROM Votes AS v JOIN Posts AS p ON v.PostId = p.Id WHERE v.VoteTypeId IN (2, 3) AND v.UserId = @userid GROUP BY p.PostTypeId, v.VoteTypeId |
### Instruction:
Average Score and Close count Percentage By Year, Month.
### Response:
| SELECT AVG(CAST(Score AS FLOAT(10, 5))) AS Avg_Score, CAST(SUM(CASE WHEN NOT ClosedDate IS NULL THEN 1 ELSE 0 END) AS FLOAT(15, 5)) / CAST(COUNT(Id) AS FLOAT(15, 5)) AS CloseCountPercentage, MONTH(CreationDate) AS month, YEAR(CreationDate) AS year FROM Posts AS p WHERE PostTypeId = 1 GROUP BY MONTH(CreationDate), YEAR(CreationDate) ORDER BY YEAR(CreationDate), MONTH(CreationDate) |
### Instruction:
When is 580 going to be offered again ?
### Response:
| SELECT DISTINCT semester.semester, semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 580 AND course_offering.semester = semester.semester_id AND semester.semester_id > (SELECT SEMESTERalias1.semester_id FROM semester AS SEMESTERalias1 WHERE SEMESTERalias1.semester = 'WN' AND SEMESTERalias1.year = 2016) ORDER BY semester.semester_id LIMIT 1 |
Subsets and Splits