instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
had patient 24268 had urine . output on the first icu visit.
### Response:
|
SELECT COUNT(*) > 0 FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 24268) 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 .' AND d_items.linksto = 'outputevents')
|
### Instruction:
what were the top three most common diagnosis until 2104?
### 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 STRFTIME('%y', diagnoses_icd.charttime) <= '2104' GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
|
### Instruction:
i'd like to know what was patient 030-77184's first respiration on the first intensive care unit visit?
### Response:
|
SELECT vitalperiodic.respiration FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-77184') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND NOT vitalperiodic.respiration IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1
|
### Instruction:
Approve Rate on Suggested User's Edits.
### Response:
|
SELECT CAST(COUNT(CASE WHEN NOT ApprovalDate IS NULL THEN 1 END) AS FLOAT) / COUNT(CASE WHEN NOT ApprovalDate IS NULL OR NOT RejectionDate IS NULL THEN 1 END) AS "Approval Rate", CAST(COUNT(CASE WHEN v.VoteTypeId = 2 THEN 1 END) AS FLOAT) / COUNT(DISTINCT v.Id) AS "Approval Vote Rate" FROM SuggestedEdits AS e LEFT JOIN SuggestedEditVotes AS v ON e.Id = v.SuggestedEditId WHERE e.OwnerUserId = @MyUserID
|
### Instruction:
combination with other organs function failure: severe liver dysfunction, severe renal insufficiency,severe heart failure ( nyha class 3 and 4 ) , acute or chronic infectious diseases, disease of immune system, asthma, malignant tumor, other advanced disease, etc.
### Response:
|
SELECT * FROM table_test_19 WHERE organ_failure = 1 OR (liver_disease = 1 OR renal_disease = 1 OR (heart_disease = 1 OR nyha_class = 3 OR nyha_class = 4) OR acute_infectious = 1 OR chronic_infectious = 1)
|
### Instruction:
how many days have passed since the first stay of patient 97330 in the ward 57 in the current hospital encounter?
### 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 = 97330 AND admissions.dischtime IS NULL)) AND transfers.wardid = 57 ORDER BY transfers.intime LIMIT 1
|
### Instruction:
Which upper-level courses are taught by Jillian Hardee ?
### 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 '%Jillian Hardee%' AND program_course.category LIKE 'ULCS'
|
### Instruction:
what was the organism found in patient 031-3355's first blood, venipuncture test on the 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 number of times does patient 92788 produce a void output since 8 months ago?
### Response:
|
SELECT COUNT(*) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 92788)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'void' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime) >= DATETIME(CURRENT_TIME(), '-8 month')
|
### Instruction:
does the first catheter tip-iv microbiology test of patient 28484 until 09/2102 have any organisms?
### Response:
|
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 28484) AND microbiologyevents.spec_type_desc = 'catheter tip-iv' AND NOT microbiologyevents.org_name IS NULL AND STRFTIME('%y-%m', microbiologyevents.charttime) <= '2102-09' ORDER BY microbiologyevents.charttime LIMIT 1
|
### Instruction:
how many days has it been since patient 25733 was last tested for bicarbonate during the current hospital visit?
### Response:
|
SELECT 1 * (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 = 'bicarbonate') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25733 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
tell me the name of the output patient 018-95228 had for the last time on the first icu visit?
### 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 = '018-95228') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND intakeoutput.cellpath LIKE '%output%' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
After 10:00 , are there any sections for CLCIV 327 ?
### 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 = 'CLCIV' AND course.number = 327 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
how many patients had a atg intake until 2 years ago?
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT icustays.hadm_id FROM icustays WHERE icustays.icustay_id IN (SELECT inputevents_cv.icustay_id FROM inputevents_cv WHERE inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'atg' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) <= DATETIME(CURRENT_TIME(), '-2 year')))
|
### Instruction:
how much patient 010-32698 weighs in 02/this year for the first time?
### Response:
|
SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-32698') AND NOT patient.admissionweight IS NULL AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', patient.unitadmittime) = '02' ORDER BY patient.unitadmittime LIMIT 1
|
### Instruction:
tell me the top five most common procedures of patients with 50s in this year?
### Response:
|
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 50 AND 59) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
indicate the daily maximum amount of sao2 for patient 022-199074 on their current hospital encounter.
### Response:
|
SELECT MAX(vitalperiodic.sao2) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-199074' AND patient.hospitaldischargetime IS NULL)) AND NOT vitalperiodic.sao2 IS NULL GROUP BY STRFTIME('%y-%m-%d', vitalperiodic.observationtime)
|
### Instruction:
has there ever been any gastric meds given to patient 2957 in their current hospital encounter?
### Response:
|
SELECT COUNT(*) > 0 FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2957 AND admissions.dischtime IS NULL)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'gastric meds' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
what was the last time patient 028-47306 had sedative agent's performed when they came to the hospital first time?
### Response:
|
SELECT treatment.treatmenttime FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-47306' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND treatment.treatmentname = 'sedative agent' ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
in 12/2105, was any organism found in patient 99647's first blood culture - neonate test?
### Response:
|
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 99647) AND microbiologyevents.spec_type_desc = 'blood culture - neonate' AND NOT microbiologyevents.org_name IS NULL AND STRFTIME('%y-%m', microbiologyevents.charttime) = '2105-12' ORDER BY microbiologyevents.charttime LIMIT 1
|
### Instruction:
Top 75 users from [Country].
### Response:
|
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Users.Id AS "user_link", Reputation, (SELECT TagName FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2 WHERE Posts.OwnerUserId = Users.Id GROUP BY TagName ORDER BY COUNT(*) DESC LIMIT 1) AS Tag FROM Users WHERE LOWER(Location) LIKE CONCAT('%', LOWER(@Country), '%') ORDER BY Reputation DESC LIMIT 75
|
### Instruction:
when was the first time that patient 85895 had the maximum chloride in a month before?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 85895) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'chloride') AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY labevents.valuenum DESC, labevents.charttime LIMIT 1
|
### Instruction:
how many patients were treated in the last year with venous cath nec?
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'venous cath nec') AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
|
### Instruction:
Show me any courses that cover parts of Contemporary Social Southeast Asia and Utilization of Nursing Advanced Practice .
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id WHERE (area.area LIKE '%Contemporary Social Southeast Asia%' OR course.description LIKE '%Contemporary Social Southeast Asia%' OR course.name LIKE '%Contemporary Social Southeast Asia%') AND (area.area LIKE '%Utilization of Nursing Advanced Practice%' OR course.description LIKE '%Utilization of Nursing Advanced Practice%' OR course.name LIKE '%Utilization of Nursing Advanced Practice%')
|
### Instruction:
Get all down votes on my posts.
### Response:
|
SELECT v.CreationDate, pt.Name, CASE p.PostTypeId WHEN 1 THEN CONCAT('http://stackoverflow.com/q/', p.Id) ELSE CONCAT('http://stackoverflow.com/a/', p.Id) END AS Link, p.Title, p.Body FROM Votes AS v LEFT JOIN VoteTypes AS vt ON vt.Id = v.VoteTypeId LEFT JOIN Posts AS p ON v.PostId = p.Id LEFT JOIN PostTypes AS pt ON pt.Id = p.PostTypeId WHERE p.OwnerUserId = '##UserId##' AND vt.Id = 3 ORDER BY CreationDate DESC
|
### Instruction:
calculate how many times patient 15794 had taken pe 24 fs ng during their current hospital 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 = 15794 AND admissions.dischtime IS NULL)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'pe 24 fs ng' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
Highest Score on SO For Answered Question That Was Not Accepted.
### Response:
|
WITH AnsweredQuestions AS (SELECT Id, AcceptedAnswerId FROM Posts WHERE PostTypeId = 1 AND NOT AcceptedAnswerId IS NULL), NonAcceptedAnswers AS (SELECT p.Id, p.ParentId, Score, RANK() OVER (ORDER BY Score DESC) AS ScoreRank FROM Posts AS p JOIN AnsweredQuestions AS aq ON p.ParentId = aq.Id WHERE p.PostTypeId = 2 AND p.Id != aq.AcceptedAnswerId) SELECT Id, ParentId, Score FROM NonAcceptedAnswers WHERE ScoreRank = 1
|
### Instruction:
How many courses for each teacher? Show me a stacked bar chart The x-axis is teacher's first name and group by course description, and display by the X in ascending.
### Response:
|
SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM GROUP BY CRS_DESCRIPTION, EMP_FNAME ORDER BY EMP_FNAME
|
### Instruction:
Given a user ID and a site, attempt to find all comments on posts that are valid for the Cleanup Cre.
### Response:
|
SELECT DISTINCT c.PostId AS "post_link", c.Text AS "Comment Text", c.Score AS "Comment Score", c.CreationDate AS "Comment Date" FROM Comments AS c JOIN PostHistory AS h ON c.PostId = h.PostId JOIN Posts AS p ON c.PostId = p.Id WHERE c.UserId = '##UserId##' AND h.CreationDate > c.CreationDate AND c.Score > 0 AND p.OwnerUserId = h.UserId AND p.OwnerUserId != '##UserId##'
|
### Instruction:
tell me the procedure that patient 81562 first had until 4 years ago?
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT procedures_icd.icd9_code FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 81562) AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-4 year') ORDER BY procedures_icd.charttime LIMIT 1)
|
### Instruction:
what are the top four most frequent diagnoses among patients of age 20s until 4 years ago?
### Response:
|
SELECT t1.diagnosisname FROM (SELECT diagnosis.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 20 AND 29) AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 4
|
### Instruction:
Suggested edit approvals / rejections by month.
### Response:
|
WITH Raw AS (SELECT COALESCE(ApprovalDate, RejectionDate) AS CreationDate, CASE WHEN NOT ApprovalDate IS NULL THEN 1 ELSE 0 END AS Approved FROM SuggestedEdits) SELECT DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) AS Month, CASE WHEN Approved = 1 THEN 'Approved' ELSE 'Rejected' END AS IsApproved, COUNT(*) AS Count FROM Raw GROUP BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1), Approved ORDER BY Month DESC, Approved
|
### Instruction:
what are the maximum total costs of a hospital involving acute respiratory distress until 1 year ago?
### 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 diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'acute respiratory distress')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### 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 department_id over the job_id , and group by attribute job_id by a bar chart, and display Y-axis from low to high order.
### Response:
|
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(DEPARTMENT_ID)
|
### Instruction:
what is the total number of input patient 027-22704 has received until 1091 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 = '027-22704')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-1091 day')
|
### Instruction:
what's the average hospital cost if there is bradycardia - complete heart block until 2102?
### 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 = 'bradycardia - complete heart block')) AND STRFTIME('%y', cost.chargetime) <= '2102' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
Up votes and down votes, questions and answers.
### Response:
|
SELECT CASE WHEN PostTypeId = 1 THEN 'Questions' ELSE 'Answers' END AS "post_type", CASE WHEN VoteTypeId = 2 THEN 'Up Votes' ELSE 'Down Votes' END AS "vote_type", COUNT(*) AS "count" FROM Posts AS p INNER JOIN Votes AS v ON p.Id = v.PostId WHERE p.ClosedDate IS NULL AND (p.PostTypeId = 1 OR p.PostTypeId = 2) AND (v.VoteTypeId = 2 OR v.VoteTypeId = 3) GROUP BY p.PostTypeId, v.VoteTypeId
|
### Instruction:
what is the total amount of output that patient 007-16517 has had today?
### 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-16517')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
what is the average hospital cost that involves a procedure, called stress ulcer treatment - antacids until 2104?
### 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 treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'stress ulcer treatment - antacids')) AND STRFTIME('%y', cost.chargetime) <= '2104' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
have patient 61500 had a closed renal biopsy procedure in 2105?
### 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 = 'closed renal biopsy') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 61500) AND STRFTIME('%y', procedures_icd.charttime) = '2105'
|
### Instruction:
what is the first thing patient 7742 had for intake on the last intensive care unit visit?
### 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 = 7742) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) ORDER BY inputevents_cv.charttime LIMIT 1)
|
### Instruction:
since 2103, what was the monthly minimum value of the rdw of patient 022-47232?
### 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-47232')) AND lab.labname = 'rdw' AND STRFTIME('%y', lab.labresulttime) >= '2103' GROUP BY STRFTIME('%y-%m', lab.labresulttime)
|
### Instruction:
how many hours has it been since the first time patient 006-157753 received procedure on the current hospital visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-157753' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime 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, visualize a bar chart about the distribution of job_id and the average of employee_id , and group by attribute job_id, sort Y-axis in asc order.
### Response:
|
SELECT JOB_ID, AVG(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(EMPLOYEE_ID)
|
### Instruction:
Average gained rep by questions and answers. It counts only accept/up/down votes on not deleted posts. PostTypeId = 1 means a question. PostTypeId = 2 means an answer.
### Response:
|
SELECT AVG(1.0 * CASE WHEN Votes.VoteTypeId = 1 THEN 15 WHEN Votes.VoteTypeId = 3 THEN -2 WHEN Posts.PostTypeId = 1 THEN 5 ELSE 10 END) AS Rep, Posts.PostTypeId FROM Posts, Votes WHERE Votes.PostId = Posts.Id AND Votes.VoteTypeId <= 3 AND Posts.PostTypeId <= 2 GROUP BY Posts.PostTypeId
|
### Instruction:
what was the name of the output patient 31854 first had in yesterday.
### 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 = 31854)) AND DATETIME(outputevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY outputevents.charttime LIMIT 1)
|
### Instruction:
whats patient 004-13672 minimum heartrate until 01/11/2103?
### Response:
|
SELECT MIN(vitalperiodic.heartrate) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-13672')) AND NOT vitalperiodic.heartrate IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) <= '2103-01-11'
|
### Instruction:
how much weight was patient 25668's last weight?
### Response:
|
SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25668)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit wt' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
what is the minimum total cost for the hospital involving a procedure called insulin this year?
### Response:
|
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'insulin')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
this year, what are the top five most frequently prescribed drugs for patients of age 60 or above?
### 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 >= 60) 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:
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, show me about the distribution of hire_date and the average of employee_id bin hire_date by time in a bar chart, and list from low to high by the y axis please.
### Response:
|
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY AVG(EMPLOYEE_ID)
|
### Instruction:
how many days is it since patient 40707 last stayed in the ward 33 during their current hospital visit?
### 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 = 40707 AND admissions.dischtime IS NULL)) AND transfers.wardid = 33 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
how much has been the total amount of intake (ml)-ng/og tube nasogastric left mouth that patient 035-166 received?
### 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 = '035-166')) AND intakeoutput.celllabel = 'intake (ml)-ng/og tube nasogastric left mouth' AND intakeoutput.cellpath LIKE '%intake%'
|
### Instruction:
what tests did patient 79919 get for the first time in 06/last year.
### Response:
|
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT labevents.itemid FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 79919) AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', labevents.charttime) = '06' ORDER BY labevents.charttime LIMIT 1)
|
### Instruction:
what is the average 60 to 64 when 50 to 54 is less than 2,054, 35 to 39 is more than 1,704, 30 to 34 is less than 1,381 and oblast\age is evenkia?
### Response:
|
SELECT AVG("60 to 64") FROM table_46411 WHERE "50 to 54" < '2,054' AND "35 to 39" > '1,704' AND "30 to 34" < '1,381' AND "Oblast\\Age" = 'evenkia'
|
### Instruction:
count how many times patient 30976 has received a entral infus nutrit sub procedure in their first 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 = 'entral infus nutrit sub') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 30976 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)
|
### Instruction:
how many hours has it been since the last time in the current hospital encounter patient 027-85328 had a procedure?
### 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 = '027-85328' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
find the total checkins in Moroccan restaurant in ' Los Angeles ' on Friday
### Response:
|
SELECT SUM(checkin.count) FROM business, category AS CATEGORY_0, category AS CATEGORY_1, checkin WHERE business.city = 'Los Angeles' AND CATEGORY_0.business_id = business.business_id AND CATEGORY_0.category_name = 'Moroccan' AND CATEGORY_1.business_id = business.business_id AND CATEGORY_1.category_name = 'restaurant' AND checkin.business_id = business.business_id AND checkin.day = 'Friday'
|
### Instruction:
in 03/2103, when was the first time that patient 006-207754 received a hgb lab test?
### 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 = '006-207754')) AND lab.labname = 'hgb' AND STRFTIME('%y-%m', lab.labresulttime) = '2103-03' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
show me the top five most common diagnoses for patients 30s of age until 1 year ago?
### Response:
|
SELECT t1.diagnosisname FROM (SELECT diagnosis.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 30 AND 39) AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
count the number of times patient 81840 had undergone other pleural incision until 2103.
### 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 = 'other pleural incision') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 81840) AND STRFTIME('%y', procedures_icd.charttime) <= '2103'
|
### Instruction:
since 12/2104, what was the daily minimum value of the pt of patient 31854?
### Response:
|
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31854) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'pt') AND STRFTIME('%y-%m', labevents.charttime) >= '2104-12' GROUP BY STRFTIME('%y-%m-%d', labevents.charttime)
|
### Instruction:
had patient 015-67291 had any csf output since 152 months ago?
### Response:
|
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-67291')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'csf' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-152 month')
|
### Instruction:
tell me the name of the test that patient 8005 first received in 03/last year?
### Response:
|
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT labevents.itemid FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8005) 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 LIMIT 1)
|
### Instruction:
during a day before, what is minimum value of systemicmean for patient 007-849?
### 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 = '007-849')) AND NOT vitalperiodic.systemicmean IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
when did patient 017-88691 last have sodium maximum since 12/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 = '017-88691')) AND lab.labname = 'sodium' AND STRFTIME('%y-%m', lab.labresulttime) >= '2105-12' ORDER BY lab.labresult DESC, lab.labresulttime DESC LIMIT 1
|
### Instruction:
how many hours has passed since patient 99883 last stayed on the current hospital visit in ward 57?
### 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 = 99883 AND admissions.dischtime IS NULL)) AND transfers.wardid = 57 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
how much is the minimum hospital bill that includes dvt - left upper extremity since 2 years 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 diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'dvt - left upper extremity')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
what was the first height of patient 006-153198 in 10/last year.
### Response:
|
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-153198') AND NOT patient.admissionheight IS NULL AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', patient.unitadmittime) = '10' ORDER BY patient.unitadmittime LIMIT 1
|
### Instruction:
Are there any upper level courses taught by Julia Sonnevend ?
### 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 '%Julia Sonnevend%' AND program_course.category LIKE 'ULCS'
|
### Instruction:
What is the lowest example of Embezzlements that have Total Convictions greater than 84,665, Fraud a figure of 1,521, and a Major Violation of Traffic Laws higher than 21,599?
### Response:
|
SELECT MIN("Embezzlement (Art. 138 StGB)") FROM table_6169 WHERE "Total Convictions" > '84,665' AND "Fraud (Art. 146 StGB)" = '1,521' AND "Major Violation of Traffic Laws (Art. 90 SVG)" > '21,599'
|
### Instruction:
how many days has it been from the last time patient 31854 received a glucose lab test on this hospital encounter?
### Response:
|
SELECT 1 * (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 = 'glucose') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31854 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
In ORALHEAL 813 is there a lab when Prof. Tamar Carroll teaches it ?
### Response:
|
SELECT COUNT(*) = 0 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 WHERE course.department = 'ORALHEAL' AND course.has_lab = 'N' AND course.number = 813 AND instructor.name LIKE '%Tamar Carroll%'
|
### Instruction:
how many hours have pass since the last time patient 1561 stayed in ward 57 in this 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 = 1561 AND admissions.dischtime IS NULL)) AND transfers.wardid = 57 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
how many days have passed since the first time patient 12927 has received a sodium-lab test on the current hospital encounter?
### Response:
|
SELECT 1 * (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 = 'sodium') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12927 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
on the current intensive care unit visit, list the daily maximum respiration of patient 006-157753.
### Response:
|
SELECT MAX(vitalperiodic.respiration) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-157753') AND patient.unitdischargetime IS NULL) AND NOT vitalperiodic.respiration IS NULL GROUP BY STRFTIME('%y-%m-%d', vitalperiodic.observationtime)
|
### Instruction:
in total, count the number of times patient 021-79656 had been prescribed tramadol 50 mg tab until 2104.
### 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 = '021-79656')) AND medication.drugname = 'tramadol 50 mg tab' AND STRFTIME('%y', medication.drugstarttime) <= '2104'
|
### Instruction:
what's the last diagnosis patient 83709 got in the last hospital visit?
### 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 = 83709 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY diagnoses_icd.charttime DESC LIMIT 1)
|
### Instruction:
Who added this [tag] to the question?.
### Response:
|
SELECT MAX(CreationDate), PostId AS "post_link", FIRST_USER AS "user_link" FROM (SELECT FIRST_VALUE(PH.UserId) OVER (PARTITION BY PH.PostId ORDER BY PH.CreationDate) AS FIRST_USER, * FROM PostHistory AS PH WHERE (PH.PostHistoryTypeId = @reTag OR PH.PostHistoryTypeId = @initTag) AND PH.Text LIKE '%<' + @tagToSearch + '>%') AS P WHERE FIRST_USER = 8404453 GROUP BY PostId, FIRST_USER
|
### Instruction:
How many answer upvotes will I get in average for each tag?.
### Response:
|
SELECT TagName, CAST(COUNT(Votes.Id) AS FLOAT) / COUNT(DISTINCT Posts.Id) AS UpVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2 WHERE Posts.PostTypeId = 2 GROUP BY TagName AND CAST(COUNT(Votes.Id) AS FLOAT) / COUNT(DISTINCT Posts.Id) > 1 ORDER BY UpVotes DESC
|
### Instruction:
how many hours has it been since the first time patient 004-79017 received a treatment in 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-79017' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
what is patient 21074's last measured height?
### Response:
|
SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 21074)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
when was last time patient 9038 was prescribed a medication via right eye route in 04/last year?
### Response:
|
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9038) AND prescriptions.route = 'right eye' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', prescriptions.startdate) = '04' ORDER BY prescriptions.startdate DESC LIMIT 1
|
### Instruction:
how many patients until 4 years ago received oxygen therapy (> 60%) - 70-80% two times?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, COUNT(*) AS c1 FROM patient WHERE patient.patientunitstayid = (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'oxygen therapy (> 60%) - 70-80%' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-4 year')) GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 = 2
|
### Instruction:
Evolution of mean score and number of questions in 2015 by week. Evolution of mean score and number of questions in 2015 by week
### Response:
|
SELECT TIME_TO_STR(p.CreationDate, '%W') AS weekOfCreation, AVG(p.Score) AS meanQuestionScore, COUNT(p.Id) AS NumberOfPosts FROM Posts AS p WHERE p.PostTypeId = 1 AND TIME_TO_STR(p.CreationDate, '%Y') = 2015 GROUP BY TIME_TO_STR(p.CreationDate, '%W') ORDER BY TIME_TO_STR(p.CreationDate, '%W')
|
### Instruction:
what was the name of the organism that was found during the last swab test of patient 62983 until 29 months ago?
### Response:
|
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 62983) AND microbiologyevents.spec_type_desc = 'swab' AND NOT microbiologyevents.org_name IS NULL AND DATETIME(microbiologyevents.charttime) <= DATETIME(CURRENT_TIME(), '-29 month') ORDER BY microbiologyevents.charttime DESC LIMIT 1
|
### Instruction:
Top 50 Sri Lankan Developers who are on Stackoverflow.
### Response:
|
SELECT ROW_NUMBER() OVER (ORDER BY Users.Reputation DESC) AS "#", Users.Id AS "user_link", Users.Location, Users.Reputation, Users.UpVotes, Users.DownVotes, (SELECT COUNT(*) FROM Posts AS PQ WHERE PostTypeId = 1 AND PQ.OwnerUserId = Users.Id) AS "questions", (SELECT COUNT(*) FROM Posts AS PA WHERE PostTypeId = 2 AND PA.OwnerUserId = Users.Id) AS "answers" FROM Users WHERE LOWER(Location) LIKE '%lanka%' ORDER BY Reputation DESC LIMIT 50
|
### Instruction:
how many days have passed since the first time during their current hospital encounter that patient 031-13920 had a procedure performed?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-13920' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
what are the number of patients who had received a open reduct mandible fx procedure since 3 years ago?
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'open reduct mandible fx') AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-3 year'))
|
### Instruction:
how many hours have passed since the last time patient 021-80293 during this hospital encounter went through a procedure?
### 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 = '021-80293' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime 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, draw a bar chart about the distribution of hire_date and the average of employee_id bin hire_date by time, and I want to display y axis from low to high order.
### Response:
|
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY AVG(EMPLOYEE_ID)
|
### Instruction:
what is the yearly average value of patient 012-26564's creatinine until 2103?
### 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 = '012-26564')) AND lab.labname = 'creatinine' AND STRFTIME('%y', lab.labresulttime) <= '2103' GROUP BY STRFTIME('%y', lab.labresulttime)
|
### Instruction:
give me the number of patients whose primary disease is neoplasm of uncertain behavior of other lymphatic and hematopoietic tissues\bone marrow transplant and drug route is dialys?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "NEOPLASM OF UNCERTAIN BEHAVIOR OF OTHER LYMPHATIC AND HEMATOPOIETIC TISSUES\BONE MARROW TRANSPLANT" AND prescriptions.route = "DIALYS"
|
### Instruction:
Old Closed Posts with no answers that weren't closed as duplicate, migrated or merged.
### Response:
|
SELECT CONCAT('id', 'post_link'), Id, ClosedDate, Score, ViewCount FROM Posts AS q WHERE PostTypeId = 1 AND CreationDate < (CURRENT_TIMESTAMP() - 30) AND COALESCE(AnswerCount, 0) = 0 AND NOT ClosedDate IS NULL AND Id NOT IN (SELECT PostId FROM PostHistory WHERE (PostHistoryTypeId = 10 AND Comment IN (1)) OR PostHistoryTypeId IN (17, 18, 35, 37, 38)) ORDER BY ClosedDate
|
### Instruction:
did patient 9038 ever undergo sm bowel endoscopy nec during the first hospital encounter?
### 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:
when patient 028-55503 was getting a prescription for the last time during a month before?
### 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 = '028-55503')) AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
what was the name of the drugs that patient 030-75705 was prescribed first the previous month.
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-75705')) AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
how many hours has it passed since the first time patient 9964 received a laboratory chloride test during their current hospital visit?
### 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 = 'chloride') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9964 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
when is the last time patient 002-13510 was prescribed medication via po in the first hospital visit?
### Response:
|
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-13510' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND medication.routeadmin = 'po' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
when did patient 006-76924 first have a heartrate measured since 1 day ago?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-76924')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-1 day') ORDER BY vitalperiodic.observationtime LIMIT 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.