instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
what is the maximum daily number of people diagnosed with poisoning-barbiturates since 2102?
### 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 = 'poisoning-barbiturates') AND STRFTIME('%y', diagnoses_icd.charttime) >= '2102' GROUP BY STRFTIME('%y-%m-%d', diagnoses_icd.charttime)) AS t1
|
### Instruction:
has patient 83466 undergone any excise lg intestine les last year?
### 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 = 'excise lg intestine les') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 83466) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
what was the name of the last intake that patient 4401 has had on 12/29/2105?
### 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 = 4401)) AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) = '2105-12-29' ORDER BY inputevents_cv.charttime DESC LIMIT 1)
|
### Instruction:
had in the previous month patient 008-46802's sao2 been normal?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '008-46802')) AND vitalperiodic.sao2 BETWEEN sao2_lower AND sao2_upper AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
|
### Instruction:
What is the most common prerequisite this semester ?
### Response:
|
SELECT COUNT(DISTINCT course_prerequisite.course_id), course.department, course.name, course.number FROM course, course_offering, course_prerequisite, semester WHERE course.course_id = course_offering.course_id AND course.course_id = course_prerequisite.pre_course_id AND course.department = 'EECS' AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 GROUP BY course_prerequisite.pre_course_id ORDER BY COUNT(course_prerequisite.course_id) DESC
|
### Instruction:
TOP Java users in Austin.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE LOWER(Location) LIKE '%texas%' AND TagName = 'java' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
### Instruction:
when patient 73595 first received exc/dest intvrt disc nos 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 = 'exc/dest intvrt disc nos') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73595) AND STRFTIME('%y', procedures_icd.charttime) <= '2104' ORDER BY procedures_icd.charttime LIMIT 1
|
### Instruction:
tell me the first value of creatinine in a lab test of patient 30307 in 10/this year?
### Response:
|
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 30307) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'creatinine') 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:
Top Android users in Sweden.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE LOWER(Location) LIKE '%tokyo%' AND TagName = 'android' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
### Instruction:
when was the first time since 03/27/2103 that patient 017-88691 had an intake?
### 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 = '017-88691')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2103-03-27' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
Top Android users in Russia.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE LOWER(Location) LIKE '%russia%' AND TagName = 'android' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
### Instruction:
count the number of times that patient 28966 had had an intake of ssc24 on the last icu visit.
### Response:
|
SELECT COUNT(*) 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 = 28966) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'ssc24' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
Average question score vs Average answer score.
### Response:
|
SELECT questions.OwnerUserId, qs, qavg, 'as', aavg, UpVotes - DownVotes AS deltavote FROM (SELECT OwnerUserId, COUNT(OwnerUserId) AS qs, AVG(Score) AS qavg FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId) AS questions INNER JOIN (SELECT OwnerUserId, COUNT(OwnerUserId) AS "as", AVG(Score) AS aavg FROM Posts WHERE PostTypeId = 2 GROUP BY OwnerUserId) AS answers ON questions.OwnerUserId = answers.OwnerUserId INNER JOIN Users ON Users.Id = questions.OwnerUserId ORDER BY qavg DESC LIMIT 1000
|
### Instruction:
what is the maximum monthly number of patients who have had orthostatic hypotension since 6 years ago?
### 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 = 'orthostatic hypotension') AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY STRFTIME('%y-%m', diagnoses_icd.charttime)) AS t1
|
### Instruction:
indicate the daily minimum amount of systemicmean for patient 006-103228 when they visited the hospital last time.
### Response:
|
SELECT MIN(vitalperiodic.systemicmean) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-103228' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND NOT vitalperiodic.systemicmean IS NULL GROUP BY STRFTIME('%y-%m-%d', vitalperiodic.observationtime)
|
### Instruction:
what is the name of the diagnosis of patient 59049 first was received during the previous year?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT diagnoses_icd.icd9_code FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 59049) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY diagnoses_icd.charttime LIMIT 1)
|
### Instruction:
when was the last time that patient 033-17325 was prescribed a medicine via intra-cathet route until 11/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 = '033-17325')) AND medication.routeadmin = 'intra-cathet' AND STRFTIME('%y-%m', medication.drugstarttime) <= '2105-11' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
Top android users from dominican.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE LOWER(Location) LIKE '%dominican%' AND TagName = 'android' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
### Instruction:
Can I attend 420 on Mondays and Wednesdays ?
### Response:
|
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course_offering.friday = 'N' AND course_offering.monday = 'Y' AND course_offering.thursday = 'N' AND course_offering.tuesday = 'N' AND course_offering.wednesday = 'Y' AND course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 420 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
what is the maximum number of patients diagnosed with ami inferior wall, init daily until 4 years ago?
### 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 = 'ami inferior wall, init') AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY STRFTIME('%y-%m-%d', diagnoses_icd.charttime)) AS t1
|
### Instruction:
what is the name of the diagnosis of patient 7073 last was received in the previous year?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT diagnoses_icd.icd9_code FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7073) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY diagnoses_icd.charttime DESC LIMIT 1)
|
### Instruction:
Bounty award // disconnect from acceptance // rep handling.
### Response:
|
SELECT p.OwnerUserId, v.*, CASE VoteTypeId WHEN 1 THEN 15 END AS accepted, CASE VoteTypeId WHEN 8 THEN -BountyAmount WHEN 9 THEN BountyAmount END AS bounty, CASE VoteTypeId WHEN 2 THEN 10 WHEN 3 THEN -2 ELSE 0 END AS rep FROM Votes AS v INNER JOIN Posts AS p ON p.Id = v.PostId INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE v.VoteTypeId IN (1, 2, 3, 8, 9) AND p.CommunityOwnedDate IS NULL ORDER BY p.OwnerUserId, v.Id
|
### Instruction:
when was the last time that on the current hospital visit patient 030-42006 was diagnosed with respiratory alkalosis - therapeutic hyperventilation.
### 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 = '030-42006' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'respiratory alkalosis - therapeutic hyperventilation' ORDER BY diagnosis.diagnosistime DESC LIMIT 1
|
### Instruction:
have any organisms been detected in patient 031-4987's last microbiological nasopharynx test since 3 years ago?
### Response:
|
SELECT COUNT(*) > 0 FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4987')) AND microlab.culturesite = 'nasopharynx' AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-3 year') ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
how many hours has it been since the last time patient 012-31752 was given a bedside glucose test during the current hospital visit?
### 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 = 'bedside glucose' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
Who have been the past instructors for BIOMEDE 401 ?
### 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 = 'BIOMEDE' AND course.number = 401 AND NOT (semester.semester = 'WN' AND semester.year = 2016)
|
### Instruction:
what is the average hospital cost when it involves pleural effusion - transudate by lab analysis in a year before?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'pleural effusion - transudate by lab analysis')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
since 907 days ago, when was the first time that patient 006-202432 had the maximum respiration?
### 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-202432')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-907 day') ORDER BY vitalperiodic.respiration DESC, vitalperiodic.observationtime LIMIT 1
|
### Instruction:
a month before has patient 016-18150 been getting any output amt-blake drain output?
### Response:
|
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-18150')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output amt-blake drain' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
|
### Instruction:
Is 520 available on Mondays and Wednesdays ?
### Response:
|
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course_offering.friday = 'N' AND course_offering.monday = 'Y' AND course_offering.thursday = 'N' AND course_offering.tuesday = 'N' AND course_offering.wednesday = 'Y' AND course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 520 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
select distinct * from posts p inner join posttags pt on pt.postid = p.id inner join tags t on pt.ta.
### Response:
|
SELECT question.Id AS QuestionId, question.Score AS QuestionScore, question.Title AS QuestionTitle, question.Body AS QuestionBody, question.Tags, answer.Id AS AcceptedAnswerId, answer.Score AS AnswerScore, answer.Body AS AnswerBody FROM Posts AS question JOIN Posts AS answer ON question.AcceptedAnswerId = answer.Id INNER JOIN PostTags AS question_tags ON question_tags.PostId = question.Id INNER JOIN Tags ON question_tags.TagId = Tags.Id WHERE question.Id > '##LastFetchedQuestionId##' AND Tags.TagName IN ('##Tag##') ORDER BY question.Id LIMIT 100
|
### Instruction:
Which customers have used both the service named 'Close a policy' and the service named 'Upgrade a policy'? Give me the customer names.
### Response:
|
SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "Close a policy" INTERSECT SELECT t1.customer_name FROM customers AS t1 JOIN first_notification_of_loss AS t2 ON t1.customer_id = t2.customer_id JOIN services AS t3 ON t2.service_id = t3.service_id WHERE t3.service_name = "New policy application"
|
### Instruction:
when was patient 4401's arterial bp mean first measured on the current icu visit?
### Response:
|
SELECT chartevents.charttime 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 = 4401) AND icustays.outtime IS NULL) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
did any 1 each vial : alteplase 2 mg ij solr ever been prescribed to patient 021-198501 since 2 years ago?
### 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 = '021-198501')) AND medication.drugname = '1 each vial : alteplase 2 mg ij solr' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-2 year')
|
### Instruction:
what is patient 007-4119's minimum value for direct bilirubin in 02/last year?
### Response:
|
SELECT MIN(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-4119')) AND lab.labname = 'direct bilirubin' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', lab.labresulttime) = '02'
|
### Instruction:
is the respiration in patient 021-246447 normal on 12/15/2104?
### 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 = '021-246447')) AND vitalperiodic.respiration BETWEEN respiration_lower AND respiration_upper AND NOT vitalperiodic.respiration IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) = '2104-12-15'
|
### Instruction:
let's count the number of times patient 28277 has received a fus/refus 9 vertebrae procedure since 4 years ago.
### Response:
|
SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'fus/refus 9 vertebrae') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 28277) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-4 year')
|
### Instruction:
KML tag with language tags (rough estimate).
### Response:
|
SELECT COUNT(DISTINCT P.Id) FROM Posts AS P INNER JOIN PostTags AS PT ON PT.PostId = P.Id INNER JOIN Tags AS T ON T.Id = PT.TagId INNER JOIN PostTags AS PT2 ON PT2.PostId = P.Id INNER JOIN Tags AS T2 ON T2.Id = PT2.TagId WHERE P.PostTypeId = 1 AND T.TagName = 'xml' AND T2.TagName IN ('javascript', 'android', 'java', 'python', 'php', 'c#', 'r', 'jquery', 'asp.net', 'python-2.7', '.net', 'css', 'mysql', 'objective-c', 'ruby')
|
### Instruction:
what is the total amount of stool out stool patient 7112 produced today?
### 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 = 'stool out stool' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
what was the total amount of urine output that patient 027-149724 had a day before?
### 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 = '027-149724')) AND intakeoutput.celllabel = 'urine' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
This Spring-Summer , ENGR 996 with be taught by whom ?
### 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 = 'ENGR' AND course.number = 996 AND semester.semester = 'Spring-Summer' AND semester.year = 2016
|
### Instruction:
what are the maximum total costs of a hospital involving ami anterolateral, init since 6 years ago?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'ami anterolateral, init')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY cost.hadm_id) AS t1
|
### Instruction:
the last time during the first hospital visit patient 56635 received a rt/left heart card cath treatment?
### Response:
|
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'rt/left heart card cath') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 56635 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) ORDER BY procedures_icd.charttime DESC LIMIT 1
|
### Instruction:
In the past , who taught WOMENSTD 300 ?
### 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 = 'WOMENSTD' AND course.number = 300 AND NOT (semester.semester = 'WN' AND semester.year = 2016)
|
### Instruction:
Next semester , who is going to teach ANTHRBIO 475 ?
### 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 = 'ANTHRBIO' AND course.number = 475 AND semester.semester = 'FA' AND semester.year = 2016
|
### Instruction:
whats the first value of calculated total co2 in 03/this year for patient 21468?
### Response:
|
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 21468) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'calculated total co2') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', labevents.charttime) = '03' ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
tell me the maximum heart rate of patient 20033 on the first intensive care unit visit?
### Response:
|
SELECT MAX(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20033) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents')
|
### Instruction:
when did patient 47460 receive a inject into thorax cavit procedure for the first time on their last hospital visit?
### 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 = 'inject into thorax cavit') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 47460 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY procedures_icd.charttime LIMIT 1
|
### Instruction:
What are the task details, task id and project id for the projects which are detailed as 'omnis' or have more than 2 outcomes?
### Response:
|
SELECT T1.task_details, T1.task_id, T2.project_id FROM tasks AS T1 JOIN projects AS T2 ON T1.project_id = T2.project_id WHERE T2.project_details = 'omnis' UNION SELECT T1.task_details, T1.task_id, T2.project_id FROM tasks AS T1 JOIN projects AS T2 ON T1.project_id = T2.project_id JOIN project_outcomes AS T3 ON T2.project_id = T3.project_id GROUP BY T2.project_id HAVING COUNT(*) > 2
|
### Instruction:
how many days have passed since patient 004-79017 was first prescribed furosemide during the current hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '004-79017') AND patient.hospitaldischargetime IS NULL) AND medication.drugname = 'furosemide' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
Questions closed or reopened the highest number of times.
### Response:
|
SELECT 'site://q/' + CAST(q.Id AS TEXT) + '/' + CAST(MIN(m.Id) AS TEXT) + '|' + MIN(q.Title) AS qti, COUNT(e.Id) AS ere, q.OwnerUserId AS "User Link" FROM Posts AS q JOIN PostHistory AS e ON q.Id = e.PostId LEFT JOIN Users AS m ON m.AccountId = 1192385 WHERE q.PostTypeId = 1 AND e.PostHistoryTypeId IN (10, 11) GROUP BY q.Id, q.OwnerUserId HAVING 3 <= COUNT(e.Id) ORDER BY ere DESC
|
### Instruction:
what is the maximum hospital cost for a drug with a name called dextrose 50 % (d50w) syringe until 2101?
### 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 medication.patientunitstayid FROM medication WHERE medication.drugname = 'dextrose 50 % (d50w) syringe')) AND STRFTIME('%y', cost.chargetime) <= '2101' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
counting new users with negative question score.
### Response:
|
WITH q_less AS (SELECT COUNT(DISTINCT u.Id) AS less_count FROM Users AS u, Posts AS p WHERE u.Id = p.OwnerUserId AND u.CreationDate >= CURRENT_TIMESTAMP() - 10 AND p.Score < 0), q_all AS (SELECT COUNT(DISTINCT u.Id) AS all_count FROM Users AS u, Posts AS p WHERE u.Id = p.OwnerUserId AND u.CreationDate >= CURRENT_TIMESTAMP() - 10) SELECT less_count, all_count, CAST(less_count AS FLOAT(10, 2)) / all_count AS ratio FROM q_less, q_all
|
### Instruction:
Top Android users in Canada.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE LOWER(Location) LIKE '%canada%' AND TagName = 'android' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
### Instruction:
what is the average yearly number of people diagnosed with posttraumatic stress dis until 2 years ago?
### 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 = 'posttraumatic stress dis') AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY STRFTIME('%y', diagnoses_icd.charttime)) AS t1
|
### Instruction:
what was the first intake of patient 29741 for the patient until 04/26/2105?
### 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 = 29741)) AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) <= '2105-04-26' ORDER BY inputevents_cv.charttime LIMIT 1)
|
### Instruction:
Question Accepted Answer Percentage by Tag.
### Response:
|
SELECT t.TagName, COUNT(DISTINCT questions.Id) AS "numquestions", COUNT(*) AS "numanswers", SUM(CASE WHEN questions.AcceptedAnswerId = answers.Id THEN 1 ELSE 0 END) AS "numaccepted", SUM(CASE WHEN questions.AcceptedAnswerId = answers.Id THEN 1 ELSE 0 END) * 100.0 / COUNT(DISTINCT questions.Id) AS "acceptedpercent" FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS questions ON questions.Id = pt.PostId INNER JOIN Posts AS answers ON answers.ParentId = questions.Id GROUP BY t.TagName ORDER BY 'acceptedpercent' DESC
|
### Instruction:
on the first icu visit, when did patient 3267 have the first urine out foley output?
### Response:
|
SELECT outputevents.charttime 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 = 3267) 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 = 'urine out foley' AND d_items.linksto = 'outputevents') ORDER BY outputevents.charttime LIMIT 1
|
### Instruction:
Accept Answer Rate for tags.
### Response:
|
SELECT t.TagName, COUNT(*) AS answers, SUM(CASE WHEN a.Id = q.AcceptedAnswerId THEN 1 ELSE 0 END) AS accepts, SUM(CASE WHEN a.Id = q.AcceptedAnswerId THEN 1 ELSE 0 END) / CAST(COUNT(*) AS FLOAT) AS acceptrate FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id INNER JOIN PostTags AS pt ON pt.PostId = q.Id INNER JOIN Tags AS t ON t.Id = pt.TagId AND q.CreationDate BETWEEN '2019-12-01' AND '2019-12-31' GROUP BY t.TagName ORDER BY COUNT(*) DESC
|
### Instruction:
posts with link IBM Cloud query for August 2020.
### Response:
|
SELECT DISTINCT Posts.Id AS "post_link", Posts.CreationDate, Posts.ViewCount, Posts.AnswerCount, Posts.CommentCount, Posts.Tags FROM Posts INNER JOIN PostTags ON PostTags.PostId = Posts.Id INNER JOIN Tags ON Tags.Id = PostTags.TagId INNER JOIN PostTypes ON PostTypes.Id = Posts.PostTypeId LEFT JOIN Users ON Users.Id = Posts.OwnerUserId WHERE Tags.TagName IN ('ibm-cloud') AND Posts.CreationDate BETWEEN 08 / 01 / 2020 AND 09 / 01 / 2020 ORDER BY Posts.Id
|
### Instruction:
what were the total cl flush: picc brachial doses patient 012-31752 had received on the first intensive care unit visit?
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-31752') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND intakeoutput.celllabel = 'cl flush: picc brachial' AND intakeoutput.cellpath LIKE '%intake%'
|
### Instruction:
Of all the classes next semester , which ones are being taught by Dr. Stacy-lynn Sant ?
### 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 '%Stacy-lynn Sant%' 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:
when did patient 002-44624 have the maximum amount of platelets x 1000 until 05/2103 for the last time?
### Response:
|
SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-44624')) AND lab.labname = 'platelets x 1000' AND STRFTIME('%y-%m', lab.labresulttime) <= '2103-05' ORDER BY lab.labresult DESC, lab.labresulttime DESC LIMIT 1
|
### Instruction:
how many times has patient 030-53416 received a heparin gtt intake until 08/28/2105?
### Response:
|
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-53416')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'heparin gtt' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2105-08-28'
|
### Instruction:
Late votes by seconds by time period of 7 days.
### Response:
|
SELECT STR_TO_TIME(v.CreationDate, '%Y%m%d') AS "day", COUNT(*) AS "late_votes" FROM Votes AS v, Posts AS p WHERE v.PostId = p.Id AND CAST((JULIANDAY(v.CreationDate) - JULIANDAY(p.CreationDate)) * 86400.0 AS INT) > 7 * 24 * 3600 AND p.OwnerUserId = '##User##' GROUP BY STR_TO_TIME(v.CreationDate, '%Y%m%d') ORDER BY STR_TO_TIME(v.CreationDate, '%Y%m%d')
|
### Instruction:
Popularity of JS, R, VBA, SQl, Python, PHP (% of all questions, by Month) [with Chart].
### Response:
|
SELECT (YEAR(p.CreationDate) * 100) + MONTH(p.CreationDate) AS yrMonth, COUNT(CASE WHEN t.TagName LIKE '%vba%' THEN 1 ELSE NULL END) AS "vba" FROM PostTags AS pt JOIN Posts AS p ON p.Id = pt.PostId JOIN Tags AS t ON t.Id = pt.TagId WHERE YEAR(p.CreationDate) >= 2018 AND p.PostTypeId = 1 GROUP BY (YEAR(p.CreationDate) * 100) + MONTH(p.CreationDate)
|
### Instruction:
For next semester , who is teaching PHARMACY 620 ?
### 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 = 'PHARMACY' AND course.number = 620 AND semester.semester = 'FA' AND semester.year = 2016
|
### Instruction:
when did patient 032-4849 have an intake for the first time since 08/16/2104?
### 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 = '032-4849')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2104-08-16' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
Top Answerers for Tag: score = weighted sum of #accepted + #votes.
### Response:
|
SELECT P.OwnerUserId AS "user_link", @AcceptWeight * SUM(CASE WHEN Q.AcceptedAnswerId = P.Id THEN 1 ELSE 0 END) + @ScoreWeight * SUM(P.Score) AS "TotalScore", COUNT(*) AS "#Answers" FROM Posts AS P INNER JOIN Posts AS Q ON Q.Id = P.ParentId INNER JOIN PostTags AS PT ON PT.PostId = Q.Id INNER JOIN Tags AS T ON T.Id = PT.TagId WHERE T.TagName = '##TagName##' AND NOT P.OwnerUserId IS NULL GROUP BY P.OwnerUserId ORDER BY 'TotalScore' DESC LIMIT 20
|
### Instruction:
Posts with Scores above and beyond awarded Bounties.
### Response:
|
SELECT P.Id AS "post_link", V.BountyAmount, (SELECT P2.Tags FROM Posts AS P2 WHERE P2.Id = P.ParentId) AS "tags", (SELECT P2.Score FROM Posts AS P2 WHERE P2.Id = P.ParentId) AS SCORES FROM Posts AS P, Votes AS V WHERE P.Id = V.PostId AND V.BountyAmount > 0 AND V.VoteTypeId = 9 AND (SELECT P2.Score FROM Posts AS P2 WHERE P2.Id = P.ParentId) > V.BountyAmount * 10 ORDER BY SCORES DESC, P.CreationDate DESC
|
### Instruction:
what is the daily average of chesttube total output of patient 032-9230 on this hospital visit?
### Response:
|
SELECT AVG(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 = '032-9230' AND patient.hospitaldischargetime IS NULL)) AND intakeoutput.celllabel = 'chesttube total' AND intakeoutput.cellpath LIKE '%output%' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
|
### Instruction:
in 05/last year was lasix prescribed to patient 021-32860?
### 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 = '021-32860')) AND medication.drugname = 'lasix' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', medication.drugstarttime) = '05'
|
### Instruction:
what is the total amount of dobutamine-in for patient 033-2671 until 580 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 = '033-2671')) AND intakeoutput.celllabel = 'dobutamine-in' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-580 day')
|
### Instruction:
If I want to take a class with Dr. Ryan Kellogg next semester , what are my choices ?
### 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 '%Ryan Kellogg%' 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 minimum total hospital cost, which includes thyrotox nos no crisis since 2 years ago?
### Response:
|
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'thyrotox nos no crisis')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.hadm_id) AS t1
|
### Instruction:
Top scores for a given tag.
### Response:
|
SELECT u.Id AS "user_link", SUM(CASE v.VoteTypeId WHEN 2 THEN 1 WHEN 3 THEN -1 END) AS Score, t.TagName FROM Users AS u INNER JOIN Posts AS a ON a.OwnerUserId = u.Id INNER JOIN Posts AS q ON q.Id = a.ParentId INNER JOIN PostTags AS pt ON pt.PostId = q.Id INNER JOIN Votes AS v ON v.PostId = a.Id INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE q.PostTypeId = 1 AND a.PostTypeId = 2 AND t.TagName = @tname GROUP BY u.Id, t.TagName ORDER BY Score DESC LIMIT 100
|
### Instruction:
when was the last time since 06/04/2103 patient 022-76925 heartrate was measured/taken?
### 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 = '022-76925')) AND NOT vitalperiodic.heartrate IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) >= '2103-06-04' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### 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 times since 658 days ago has patient 1269 received br milk fs ng?
### Response:
|
SELECT COUNT(*) 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 = 1269)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'br milk fs ng' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) >= DATETIME(CURRENT_TIME(), '-658 day')
|
### 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:
how many hours is it since patient 004-64091 first received neurology consultation during their current hospital encounter?
### 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 = '004-64091' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'neurology consultation' ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
Does the class meet for AERO 411 often ?
### Response:
|
SELECT DISTINCT course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'AERO' AND course.number = 411 AND semester.semester = 'WN' AND semester.year = 2016
|
### Instruction:
until 64 months ago, when was the first time that patient 006-167444 was prescribed with a medication via intravenous 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 = '006-167444')) AND medication.routeadmin = 'intravenous' AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-64 month') ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
what is the daily minimum value of patient 022-187132's magnesium during this month?
### Response:
|
SELECT MIN(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-187132')) AND lab.labname = 'magnesium' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') GROUP BY STRFTIME('%y-%m-%d', lab.labresulttime)
|
### Instruction:
In reference to EPID 813 , who has taught it 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 = 'EPID' AND course.number = 813 AND NOT (semester.semester = 'WN' AND semester.year = 2016)
|
### Instruction:
tell me the name of the organism that was detected in the first nasopharynx test of patient 031-16123 during their first hospital visit?
### Response:
|
SELECT microlab.organism FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-16123' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND microlab.culturesite = 'nasopharynx' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
what is the minimum yearly number of patients that are suffering from allergic rhinitis nos until 2104?
### 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 = 'allergic rhinitis nos') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104' GROUP BY STRFTIME('%y', diagnoses_icd.charttime)) AS t1
|
### 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:
has patient 007-8693 undergone any procedures for therapeutic antibacterials - penicillins during the last year?
### Response:
|
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-8693')) AND treatment.treatmentname = 'therapeutic antibacterials - penicillins' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
when was last time patient 031-24513 had the minimum sao2 value until 364 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 = '031-24513')) AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-364 day') ORDER BY vitalperiodic.sao2, vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
what intake did patient 016-20141 take until 08/07/2105 for the last time?
### 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-20141')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2105-08-07' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
provide the monthly maximum amount of per iv flush: antecubital l 20 gauge that patient 007-7646 has received.
### Response:
|
SELECT MAX(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-7646')) AND intakeoutput.celllabel = 'per iv flush: antecubital l 20 gauge' AND intakeoutput.cellpath LIKE '%intake%' GROUP BY STRFTIME('%y-%m', intakeoutput.intakeoutputtime)
|
### Instruction:
is there any results of the microbiology test carried out for patient 031-1337 in 05/this year?
### Response:
|
SELECT COUNT(*) > 0 FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-1337')) AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', microlab.culturetakentime) = '05'
|
### Instruction:
Questions that I've answered and closed as duplicate.
### Response:
|
WITH ClosedQuestions AS (SELECT Q.Id FROM Posts AS Q INNER JOIN PostHistory AS PH ON Q.Id = PH.PostId WHERE PH.PostHistoryTypeId = 10), ClosedByMeQuestions AS (SELECT Q.Id FROM ClosedQuestions AS Q INNER JOIN Votes AS V ON Q.Id = V.PostId WHERE V.UserId = '##UserId##' AND V.VoteTypeId = 6) SELECT Q.Id AS "post_link" FROM Posts AS A INNER JOIN ClosedByMeQuestions AS Q ON A.ParentId = Q.Id WHERE A.OwnerUserId = '##UserId##' AND A.PostTypeId = 2
|
### Instruction:
what is the drug that has been prescribed patient 8773 for two times in 12/last year?
### Response:
|
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8773) AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', prescriptions.startdate) = '12' GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
|
### Instruction:
For 453 prerequisites , which are human computer interaction courses ?
### Response:
|
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0 INNER JOIN course_prerequisite ON COURSE_0.course_id = course_prerequisite.pre_course_id INNER JOIN course AS COURSE_1 ON COURSE_1.course_id = course_prerequisite.course_id INNER JOIN area ON COURSE_0.course_id = area.course_id WHERE area.area LIKE '%human computer interaction%' AND COURSE_1.department = 'department0' AND COURSE_1.number = 453
|
### Instruction:
what is the average hospital cost for a patient suffering from fracture of pubis-closed since 2105?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'fracture of pubis-closed')) AND STRFTIME('%y', cost.chargetime) >= '2105' GROUP BY cost.hadm_id) AS t1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.