instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
tell me the five most frequent medical diagnoses until 1 year ago?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
Next semester , what classes is Dr. Daniel Ferris teaching ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Daniel Ferris%' 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:
Fastest Rep Gainers in Germany.
### Response:
|
WITH GermanUsers AS (SELECT Id, Location, AboutMe, CreationDate, LastAccessDate, Reputation, CAST((LastAccessDate - CreationDate) AS FLOAT) AS TimeOnSite FROM Users WHERE LOWER(Location) LIKE '%germany%' OR LOWER(Location) LIKE '%deutschland%') SELECT Id AS "user_link", Location, AboutMe, TimeOnSite, Reputation, (CAST(Reputation AS FLOAT) / TimeOnSite) AS AvgRepPerDay FROM GermanUsers WHERE TimeOnSite > 0 AND YEAR(CreationDate) < 2017 ORDER BY AvgRepPerDay DESC LIMIT 100
|
### Instruction:
what is the total output of patient 022-121402 since 06/19/2102?
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-121402')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2102-06-19'
|
### Instruction:
count the number of times patient 46528 had received an extracran-intracr bypass during the last hospital visit.
### 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 = 'extracran-intracr bypass') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 46528 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)
|
### Instruction:
CW Answers (converted by moderator) that were later edited.
### Response:
|
WITH CWAnswers AS (SELECT Posts.Id AS "post_link", Posts.LastEditDate, Posts.CommunityOwnedDate, Posts.LastEditorUserId AS "user_link" FROM PostHistory INNER JOIN Posts ON Posts.Id = PostHistory.PostId WHERE PostHistory.PostHistoryTypeId = 16 AND PostHistory.UserId != Posts.OwnerUserId AND Posts.PostTypeId = 2 AND Posts.CreationDate > '2016-09-01') SELECT * FROM CWAnswers WHERE CommunityOwnedDate > LastEditDate OR LastEditDate IS NULL
|
### Instruction:
has patient 3277's temperature c (calc) been 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 = 3277)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'temperature c (calc)' AND d_items.linksto = 'chartevents') AND chartevents.valuenum BETWEEN temperature_lower AND temperature_upper
|
### Instruction:
Combined Reputation of Bottom X% of Users. Determines the combined reputation of all users, excluding the specified top percent
### Response:
|
WITH Rankings AS (SELECT Id, Reputation, Ranking = ROW_NUMBER() OVER (ORDER BY Reputation DESC) FROM Users), Counts AS (SELECT Count = COUNT(*) FROM Users), RankedUsers AS (SELECT Reputation, CAST(Ranking AS FLOAT(10, 5)) / (SELECT Count FROM Counts) AS Percentile FROM Rankings) SELECT SUM(Reputation) AS "Combined Reputation", COUNT(*) AS "# Users Represented" FROM RankedUsers WHERE Percentile > '##ExcludingTopPercent##' / 100.0
|
### Instruction:
had patient 83499 undergone the insert vasc access dev operation since 2 years ago?
### 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 = 'insert vasc access dev') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 83499) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-2 year')
|
### Instruction:
what were the five most frequent lab tests ordered since 2104 for patients in the age of 60 or above?
### Response:
|
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t1.itemid FROM (SELECT labevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age >= 60) AND STRFTIME('%y', labevents.charttime) >= '2104' GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
Questions that where not answered after editing. Questions that got at least one answer even after being edited.
### Response:
|
SELECT q.Id AS "post_link", q.Tags AS "tags", q.ViewCount AS "views", q.Score AS "votes" FROM Posts AS q LEFT OUTER JOIN Tags ON q.Tags = Tags.TagName WHERE q.PostTypeId = 1 AND q.LastEditorUserId = '##userid##' AND q.ClosedDate IS NULL AND q.CommunityOwnedDate IS NULL AND q.ParentId IS NULL AND q.AcceptedAnswerId IS NULL AND q.AnswerCount < 1 AND DATEDIFF(day, q.CreationDate, LastEditDate) < 30
|
### Instruction:
did patient 030-47098 ever have a chemotherapy procedure in any other hospital since 2105?
### Response:
|
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '030-47098' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '030-47098' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'chemotherapy' AND STRFTIME('%y', treatment.treatmenttime) >= '2105'
|
### Instruction:
how many times have patient 75762 been treated with lumb/lmbsac fus ant/post on their first hospital visit?
### 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 = 'lumb/lmbsac fus ant/post') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 75762 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)
|
### Instruction:
did patient 035-11300 have a normal heartrate when they came to the hospital first time?
### 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 = '035-11300' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND vitalperiodic.heartrate BETWEEN heart_rate_lower AND heart_rate_upper AND NOT vitalperiodic.heartrate IS NULL
|
### Instruction:
count how many times until 2104 patient 73595 has had a exc/dest intvrt disc nos.
### 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 = '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'
|
### Instruction:
My answers to bad questions.
### Response:
|
SELECT CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END AS "accepted", a.Score AS "score", a.Id AS "post_link", q.ClosedDate AS "date_closed", a.CreationDate AS "date_posted" FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id WHERE NOT q.ClosedDate IS NULL AND NOT EXISTS(SELECT 1 FROM PostHistory WHERE PostId = q.Id AND CreationDate = q.ClosedDate AND PostHistoryTypeId = 10 AND Comment NOT IN (101, 1)) AND a.OwnerUserId = '##UserId##'
|
### Instruction:
have patient 013-23115 had a lung biopsy - transbronchial procedure during this 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 = '013-23115')) AND treatment.treatmentname = 'lung biopsy - transbronchial' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
Answers with the highest score per question view.
### Response:
|
SELECT CAST(a.Score AS FLOAT) / q.ViewCount AS ScorePerQuestionView, a.Id AS "post_link", a.Score, q.ViewCount, a.Body AS AnswerBody, a.OwnerUserId AS "user_link", a.CreationDate AS AnswerCreationDate, q.Body AS QuestionBody, q.CreationDate AS QuestionCreationDate, q.Tags, q.AnswerCount FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id WHERE a.PostTypeId = 2 AND q.ViewCount > 1000 ORDER BY ScorePerQuestionView DESC LIMIT 141
|
### Instruction:
retrieve the patients ids who had been diagnosed with ischemic optic neuropthy in this year.
### Response:
|
SELECT admissions.subject_id FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'ischemic optic neuropthy') AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
|
### Instruction:
has patient 56201 been potassium, whole blood tested in 01/this year?
### Response:
|
SELECT COUNT(*) > 0 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'potassium, whole blood') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 56201) AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', labevents.charttime) = '01'
|
### Instruction:
give me a total of patient 005-87465's output on 12/21/2105.
### 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 = '005-87465')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2105-12-21'
|
### Instruction:
what is the ground transportation from PHL airport to the city proper
### 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 = 'PHILADELPHIA' AND CITY_1.city_code = airport_service.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_0.city_code
|
### Instruction:
what are the top four procedures that are received the most frequently until 3 years ago?
### 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) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
had on the last icu visit patient 006-158338's sao2 been greater than 94.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 = '006-158338') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND vitalperiodic.sao2 > 94.0 AND NOT vitalperiodic.sao2 IS NULL
|
### Instruction:
provide me with the five most common diagnosis since 1 year ago.
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
has patient 011-20295 been diagnosed with seizures - new onset in a year before.
### Response:
|
SELECT COUNT(*) > 0 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '011-20295')) AND diagnosis.diagnosisname = 'seizures - new onset' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
has patient 20589 received a nodular lymphoma mult diagnosis during their last hospital visit?
### 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 = 'nodular lymphoma mult') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20589 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)
|
### Instruction:
what was the drug patient 016-1459 was prescribed for the first time until 4 months ago using the intraven route?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-1459')) AND medication.routeadmin = 'intraven' AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-4 month') ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
what was the top three most frequent diagnoses until 3 years ago?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
|
### Instruction:
what is the monthly minimum amount of cholesterol, ldl, measured patient 13806 has until 2104?
### Response:
|
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13806) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'cholesterol, ldl, measured') AND STRFTIME('%y', labevents.charttime) <= '2104' GROUP BY STRFTIME('%y-%m', labevents.charttime)
|
### Instruction:
how many times patient 75170 has received remov imp dev-tib/fibula during their last hospital encounter?
### 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 = 'remov imp dev-tib/fibula') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 75170 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)
|
### Instruction:
what was the name of the organism found in the microbiology test of the last throat culture of patient 4469 since 168 months ago?
### Response:
|
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 4469) AND microbiologyevents.spec_type_desc = 'throat culture' AND NOT microbiologyevents.org_name IS NULL AND DATETIME(microbiologyevents.charttime) >= DATETIME(CURRENT_TIME(), '-168 month') ORDER BY microbiologyevents.charttime DESC LIMIT 1
|
### Instruction:
when is the first time that patient 028-11360 has had a sao2 measured on the last intensive care unit visit?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-11360') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.sao2 IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1
|
### Instruction:
When are the COMPLIT 374 classes in the week .
### Response:
|
SELECT DISTINCT course_offering.friday, course_offering.monday, course_offering.saturday, course_offering.sunday, course_offering.thursday, course_offering.tuesday, course_offering.wednesday FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'COMPLIT' AND course.number = 374 ORDER BY semester.year DESC
|
### Instruction:
Most popular data analysis languages by month and year.
### Response:
|
SELECT YEAR(Posts.CreationDate) AS year, MONTH(Posts.CreationDate) AS month, Tags.TagName AS language, COUNT(Tags.TagName) AS posts FROM Posts, Tags WHERE Tags.TagName IN ('r', 'python', 'java', 'stata', 'matlab', 'sas', 'tableau') AND Posts.Tags LIKE ('%<' + Tags.TagName + '>%') GROUP BY Tags.TagName, YEAR(Posts.CreationDate), MONTH(Posts.CreationDate) ORDER BY Tags.TagName, YEAR(Posts.CreationDate), MONTH(Posts.CreationDate)
|
### Instruction:
tag answer count (2014 - today).
### Response:
|
SELECT t.TagName, t.Count AS tagCount, SUM(q.AnswerCount) AS answCnt FROM Posts AS q INNER JOIN Posts AS a ON q.AcceptedAnswerId = a.Id INNER JOIN PostTags AS pt ON pt.PostId = q.Id INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE q.Id != a.Id AND q.OwnerUserId != a.OwnerUserId AND q.CreationDate >= '2014-01-01' AND q.PostTypeId = 1 AND a.PostTypeId = 2 GROUP BY t.TagName, t.Count ORDER BY answCnt DESC
|
### Instruction:
List a user's rejected suggested edits. List all the rejected suggested edits proposed by a given user.
### Response:
|
SELECT 'site://suggested-edits/' + CAST(s.Id AS TEXT(20)) + '|' + CASE LENGTH(LTRIM(s.Comment)) WHEN 0 THEN 'none' ELSE s.Comment END AS "suggested_edit", s.PostId AS "post_link", s.CreationDate AS "creation_date", s.RejectionDate AS "rejection_date" FROM SuggestedEdits AS s WHERE s.OwnerUserId = '##UserId##' AND NOT s.RejectionDate IS NULL ORDER BY s.RejectionDate DESC
|
### Instruction:
What are the forenames and surnames of drivers who participated in the races named Australian Grand Prix but not the races named Chinese Grand Prix?
### Response:
|
SELECT T3.forename, T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename, T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"
|
### Instruction:
In every semester , can you take ENDODONT 651 ?
### Response:
|
SELECT COUNT(*) > 0 FROM semester WHERE NOT semester IN (SELECT DISTINCT SEMESTERalias1.semester FROM course AS COURSEalias0, course_offering AS COURSE_OFFERINGalias0, semester AS SEMESTERalias1 WHERE COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id AND COURSEalias0.department = 'ENDODONT' AND COURSEalias0.number = 651 AND SEMESTERalias1.semester_id = COURSE_OFFERINGalias0.semester)
|
### Instruction:
get me patient 002-39753's total input until 09/29/2102.
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-39753')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2102-09-29'
|
### Instruction:
Tags which no longer exists (ordered by number of questions).
### Response:
|
WITH tagshistory_cte AS (SELECT Id AS phid, REPLACE(value, '>', '') AS TagName FROM PostHistory JOIN LATERAL STRING_SPLIT(Text, '<') WHERE PostHistoryTypeId IN (3, 6, 9) AND LENGTH(value) > 0) SELECT th.TagName, COUNT(DISTINCT ph.PostId) AS "count" FROM tagshistory_cte AS th INNER JOIN PostHistory AS ph ON ph.Id = th.phid WHERE (th.TagName NOT IN (SELECT TagName FROM Tags)) GROUP BY th.TagName ORDER BY COUNT(DISTINCT ph.PostId) DESC
|
### Instruction:
what is the monthly average amount of cortisol patient 017-66654 has since 6 years ago?
### Response:
|
SELECT AVG(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-66654')) AND lab.labname = 'cortisol' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY STRFTIME('%y-%m', lab.labresulttime)
|
### Instruction:
what was the total quantity of output that patient 007-1517 had until 03/09/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 = '007-1517')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2104-03-09'
|
### Instruction:
what is the daily average amount of glucose of patient 025-35599 until 4 years ago?
### Response:
|
SELECT AVG(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-35599')) AND lab.labname = 'glucose' AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY STRFTIME('%y-%m-%d', lab.labresulttime)
|
### Instruction:
what is the number of times patient 002-41152 has been prescribed metformin hcl 500 mg po tabs since 2105.
### 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 = '002-41152')) AND medication.drugname = 'metformin hcl 500 mg po tabs' AND STRFTIME('%y', medication.drugstarttime) >= '2105'
|
### Instruction:
Which is the first paper by richard bellman ?
### Response:
|
SELECT DISTINCT paper.paperid, paper.year FROM author, paper, writes WHERE author.authorname = 'richard bellman' AND paper.year = (SELECT MIN(PAPERalias1.year) FROM author AS AUTHORalias1, paper AS PAPERalias1, writes AS WRITESalias1 WHERE AUTHORalias1.authorname = 'richard bellman' AND WRITESalias1.authorid = AUTHORalias1.authorid AND WRITESalias1.paperid = PAPERalias1.paperid) AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
|
### Instruction:
what is the daily maximum value of patient 011-35642's base excess until 30 months ago?
### 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 = '011-35642')) AND lab.labname = 'base excess' AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-30 month') GROUP BY STRFTIME('%y-%m-%d', lab.labresulttime)
|
### Instruction:
list the ids of all those patients diagnosed with ac alcoholic hepatitis during the previous year.
### Response:
|
SELECT admissions.subject_id FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'ac alcoholic hepatitis') AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
|
### Instruction:
the previous year, what are the top five frequently ordered prescriptions for patients 50s?
### Response:
|
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 50 AND 59) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
tell me the name of the first specimen test patient 031-3355 had received this month?
### Response:
|
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-3355')) AND DATETIME(microlab.culturetakentime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
how many times does patient 027-82318 have a urine output a day before?
### Response:
|
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-82318')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'urine' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
does patient 005-77687 produce any rectal tube in 12/2105.
### Response:
|
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-77687')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'rectal tube' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) = '2105-12'
|
### Instruction:
has patient 60219 received the procedure of a inject/inf thrombo agent until 2104?
### 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 = 'inject/inf thrombo agent') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 60219) AND STRFTIME('%y', procedures_icd.charttime) <= '2104'
|
### Instruction:
what is the total amount of total output of patient 13686 on 07/28/this year?
### Response:
|
SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13686)) AND DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', outputevents.charttime) = '07-28'
|
### Instruction:
Which upper-level courses does Deborah Keller-cohen teach ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number 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 program_course ON program_course.course_id = course.course_id WHERE instructor.name LIKE '%Deborah Keller-cohen%' AND program_course.category LIKE 'ULCS'
|
### Instruction:
Tomcat Related Posts with Tags of Security or Performance.
### Response:
|
SELECT Id, Title + REPLACE(REPLACE(Tags, '<', ' '), '>', ' ') + REPLACE(REPLACE(Body, CHAR(13), ''), CHAR(10), '') AS txt FROM Posts WHERE CreationDate > '2000-01-01' AND (Title LIKE '%java%' OR Body LIKE '%java%' OR Tags LIKE '%java%') AND (Body LIKE '%performance%' OR Body LIKE '%better%' OR Body LIKE '%efficient%' OR Body LIKE '%faster%') AND (NOT Tags LIKE '%performance%') AND (NOT Tags LIKE '%seurity%') LIMIT 1000
|
### Instruction:
What section after 10:45 A.M. is in PSYCH 513 ?
### Response:
|
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '10:45' AND course.course_id = course_offering.course_id AND course.department = 'PSYCH' AND course.number = 513 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
what was the organism found in the first blood, venipuncture microbiological test of patient 031-3355 during their current 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-3355' AND patient.hospitaldischargetime IS NULL)) AND microlab.culturesite = 'blood, venipuncture' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
what's the total output that patient 009-1746 has had until 12/28/2105?
### 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 = '009-1746')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2105-12-28'
|
### Instruction:
had patient 23224's heart rate ever been less than 59.0 degrees?
### 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 = 23224)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND chartevents.valuenum < 59.0
|
### Instruction:
count how many drugs are prescribed to patient 030-44598 in 12/this year.
### 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 = '030-44598')) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '12'
|
### Instruction:
had patient 007-6603 been diagnosed as traumatic injury to major vessels - r carotid artery in 2105?
### Response:
|
SELECT COUNT(*) > 0 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-6603')) AND diagnosis.diagnosisname = 'traumatic injury to major vessels - r carotid artery' AND STRFTIME('%y', diagnosis.diagnosistime) = '2105'
|
### Instruction:
what is the minimum total cost of the hospital which include tacrolimus-fk506 until 1 year ago?
### Response:
|
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT lab.patientunitstayid FROM lab WHERE lab.labname = 'tacrolimus-fk506')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
show me the top five most often prescribed drugs for patients 20s during this year?
### Response:
|
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 20 AND 29) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
when did patient 021-25705 last have the minimum anion gap value this month?
### Response:
|
SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-25705')) AND lab.labname = 'anion gap' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY lab.labresult, lab.labresulttime DESC LIMIT 1
|
### Instruction:
what is the monthly maximum value of patient 013-9305's urinary osmolality since 2103?
### 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 = '013-9305')) AND lab.labname = 'urinary osmolality' AND STRFTIME('%y', lab.labresulttime) >= '2103' GROUP BY STRFTIME('%y-%m', lab.labresulttime)
|
### Instruction:
how many times did patient 32486 do a void in 07/2100?
### 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 = 32486)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'void' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m', outputevents.charttime) = '2100-07'
|
### Instruction:
get the id's of the patients who were diagnosed with primary hyperparathyroid during this year.
### Response:
|
SELECT admissions.subject_id FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'primary hyperparathyroid') AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
|
### Instruction:
what allergy does patient 018-118331 has in 01/this year?
### Response:
|
SELECT allergy.allergyname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '018-118331')) AND DATETIME(allergy.allergytime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', allergy.allergytime) = '01'
|
### Instruction:
what was the last output since 10/10/2100 for patient 25796?
### 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 = 25796)) AND STRFTIME('%y-%m-%d', outputevents.charttime) >= '2100-10-10' ORDER BY outputevents.charttime DESC LIMIT 1)
|
### Instruction:
when did patient 027-22704 have the maximum lactate value in 12/2101 the first 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 = '027-22704')) AND lab.labname = 'lactate' AND STRFTIME('%y-%m', lab.labresulttime) = '2101-12' ORDER BY lab.labresult DESC, lab.labresulttime LIMIT 1
|
### Instruction:
Top 500 answerers on the site (by count). A list of the top 500 users with the highest average answer score excluding
community wiki / closed posts or users with less than 10 answers
### Response:
|
SELECT ROW_NUMBER() OVER (ORDER BY COUNT(Posts.Id) DESC) AS Rank, Users.Id AS "user_link", COUNT(Posts.Id) AS Answers FROM Posts INNER JOIN Users ON Users.Id = OwnerUserId WHERE PostTypeId = 2 AND CommunityOwnedDate IS NULL AND ClosedDate IS NULL GROUP BY Users.Id, DisplayName HAVING COUNT(Posts.Id) > 10 ORDER BY Answers DESC LIMIT 500
|
### Instruction:
when was the last time patient 031-1337 had a microbiology test, since 117 months ago?
### Response:
|
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-1337')) AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-117 month') ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
To take CEE 621 and 611 , what prerequisites are necessary ?
### Response:
|
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE (COURSE_1.number = 621 OR COURSE_1.number = 611) AND COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'CEE'
|
### Instruction:
when was patient 10624 on this hospital encounter last diagnosed with cardiac tamponade?
### Response:
|
SELECT diagnoses_icd.charttime FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'cardiac tamponade') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10624 AND admissions.dischtime IS NULL) ORDER BY diagnoses_icd.charttime DESC LIMIT 1
|
### Instruction:
tell me the name of the first specimen test that patient 031-24513 until 08/2104 received?
### Response:
|
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-24513')) AND STRFTIME('%y-%m', microlab.culturetakentime) <= '2104-08' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
since 12/2105, patient 006-80884 has had any levo intake?
### 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 = '006-80884')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'levo' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) >= '2105-12'
|
### Instruction:
Votes on posts that are neither questions nor answers.
### Response:
|
SELECT p.Id AS "post_link", p.Id AS "post_id", pt.Name AS "post_type", vt.Name AS "vote_type", v.UserId AS "user_link", v.CreationDate AS "vote_date", p.Body FROM Votes AS v JOIN Posts AS p ON v.PostId = p.Id JOIN PostTypes AS pt ON p.PostTypeId = pt.Id JOIN VoteTypes AS vt ON v.VoteTypeId = vt.Id WHERE pt.Name NOT IN ('Question', 'Answer') AND vt.Name NOT IN ('Deletion', 'ApproveEditSuggestion')
|
### Instruction:
Bounties: on own questions vs. others' questions.
### Response:
|
SELECT SUM(CASE v.UserId WHEN p.OwnerUserId THEN 1 ELSE 0 END) AS "Own", 100 * SUM(CASE v.UserId WHEN p.OwnerUserId THEN 1 ELSE 0 END) / COUNT(*) AS "%", SUM(CASE v.UserId WHEN p.OwnerUserId THEN 0 ELSE 1 END) AS "Other", 100 * SUM(CASE v.UserId WHEN p.OwnerUserId THEN 0 ELSE 1 END) / COUNT(*) AS "%" FROM Votes AS v INNER JOIN Posts AS p ON v.PostId = p.Id WHERE v.VoteTypeId = 8
|
### Instruction:
how many hours have it been since the last time that patient 10855 stayed in ward 50 during their current hospital encounter?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10855 AND admissions.dischtime IS NULL)) AND transfers.wardid = 50 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
What prerequisites do I need for EHS 616 and 615 ?
### Response:
|
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE (COURSE_1.number = 616 OR COURSE_1.number = 615) AND COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'EHS'
|
### Instruction:
what was the total number of outputs patient 56490 had on 09/10/last year?
### Response:
|
SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 56490)) AND DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', outputevents.charttime) = '09-10'
|
### Instruction:
since 27 months ago what was the first time of patient 031-24513's microbiology test?
### Response:
|
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-24513')) AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-27 month') ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
for the last time in 01/last year, when was patient 1912 prescribed for atorvastatin?
### Response:
|
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1912) AND prescriptions.drug = 'atorvastatin' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', prescriptions.startdate) = '01' ORDER BY prescriptions.startdate DESC LIMIT 1
|
### Instruction:
what is the count of times that patient 77987 had received a specific gravity lab test in 09/last year.
### Response:
|
SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'specific gravity') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 77987) AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', labevents.charttime) = '09'
|
### Instruction:
when they came to the hospital first time, has patient 9038 had a sm bowel endoscopy nec procedure?
### Response:
|
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'sm bowel endoscopy nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9038 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)
|
### Instruction:
has patient 004-79017 excreted any urine today.
### 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 = '004-79017')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'urine' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
Are Prof. Karie Slavik and Prof. Stephen Rush the only teachers who teach MCDB 310 ?
### Response:
|
SELECT COUNT(*) = 0 FROM course, course_offering, instructor, offering_instructor WHERE (NOT instructor.name LIKE '%Karie Slavik%' AND NOT instructor.name LIKE '%Stephen Rush%') AND course.course_id = course_offering.course_id AND course.department = 'MCDB' AND course.number = 310 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
|
### Instruction:
did patient 005-87465 had output (ml)-chest tube #1 pleural left output on the current intensive care unit visit?
### Response:
|
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-87465') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output (ml)-chest tube #1 pleural left'
|
### Instruction:
what was the name of the specimen test that patient 031-22988 was first to receive until 32 months ago?
### Response:
|
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-22988')) AND DATETIME(microlab.culturetakentime) <= DATETIME(CURRENT_TIME(), '-32 month') ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
how many days have passed since patient 10855 stayed in the ward 50 in their current hospital visit for the last time?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10855 AND admissions.dischtime IS NULL)) AND transfers.wardid = 50 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of manager_id over the job_id , and group by attribute job_id by a bar chart, I want to order in desc by the mean manager id please.
### Response:
|
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(MANAGER_ID) DESC
|
### Instruction:
What upper-level electives do n't meet on Monday or Friday and are offered next semester ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course_offering.friday = 'N' AND course_offering.monday = 'N' AND course.course_id = course_offering.course_id AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
when did patient 021-239662 first receive an dka diagnosis during their last hospital encounter?
### Response:
|
SELECT diagnosis.diagnosistime FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-239662' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND diagnosis.diagnosisname = 'dka' ORDER BY diagnosis.diagnosistime LIMIT 1
|
### Instruction:
Users who actively participate (at least 1 question and answer) By Join Date.
### Response:
|
SELECT YEAR(Users.CreationDate) AS cYear, MONTH(Users.CreationDate) AS cMonth, COUNT(*) AS askedAndAnswered FROM (SELECT DISTINCT OwnerUserId FROM Posts WHERE PostTypeId = 1) AS P1 JOIN (SELECT DISTINCT OwnerUserId FROM Posts WHERE PostTypeId = 2) AS P2 ON P1.OwnerUserId = P2.OwnerUserId JOIN Users ON P1.OwnerUserId = Users.Id GROUP BY YEAR(Users.CreationDate), MONTH(Users.CreationDate) ORDER BY 1, 2
|
### Instruction:
After 10:00 , does PEDDENT 598 have any sections ?
### Response:
|
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '10:00' AND course.course_id = course_offering.course_id AND course.department = 'PEDDENT' AND course.number = 598 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
what is the first value of the bedside glucose of patient 002-58884 a month before?
### Response:
|
SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-58884')) AND lab.labname = 'bedside glucose' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
what is the yearly minimum amount of bilirubin, total, ascites patient 31243 has since 2104?
### Response:
|
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31243) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'bilirubin, total, ascites') AND STRFTIME('%y', labevents.charttime) >= '2104' GROUP BY STRFTIME('%y', labevents.charttime)
|
### Instruction:
what was the first time patient 030-75705 had the minimum level of -eos since 09/2105?
### Response:
|
SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-75705')) AND lab.labname = '-eos' AND STRFTIME('%y-%m', lab.labresulttime) >= '2105-09' ORDER BY lab.labresult, lab.labresulttime LIMIT 1
|
### Instruction:
how many hours have elapsed since patient 2518 first received a laboratory fibrinogen, functional test on their current hospital encounter?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', labevents.charttime)) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'fibrinogen, functional') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2518 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime LIMIT 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.