instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
how many hours have passed since the first procedure on the current hospital encounter for patient 032-21820?
### 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 = '032-21820' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
what is patient 93078's yearly maximum level of folate since 12/2105?
### Response:
|
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 93078) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'folate') AND STRFTIME('%y-%m', labevents.charttime) >= '2105-12' GROUP BY STRFTIME('%y', labevents.charttime)
|
### 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 sum of department_id over the job_id , and group by attribute job_id, and could you rank Y-axis from low to high order?
### Response:
|
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(DEPARTMENT_ID)
|
### Instruction:
Users with Images in their AboutME.
### Response:
|
SELECT Id AS "user_link", Reputation, DisplayName, AboutMe FROM Users WHERE LOWER(AboutMe) LIKE '%great firewall%' OR LOWER(DisplayName) LIKE '%great firewall%' OR LOWER(AboutMe) LIKE '%tian an men%' OR LOWER(DisplayName) LIKE '%tian an men%' OR LOWER(AboutMe) LIKE '%tiananmen%' OR LOWER(DisplayName) LIKE '%tiananmen%' OR LOWER(AboutMe) LIKE '%falun%' OR LOWER(DisplayName) LIKE '%falun%' ORDER BY Reputation DESC LIMIT 256
|
### Instruction:
what is the drug that has been prescribed patient 14467 for two or more times in this month?
### Response:
|
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14467) AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 >= 2
|
### Instruction:
Get users with multiple accounts. Ordered by Account-Number and Reputation
### Response:
|
SELECT Id AS "user_link", Accounts, Reputation, LastAccessDate FROM (SELECT ROW_NUMBER() OVER (PARTITION BY EmailHash ORDER BY u1.Reputation DESC) AS Rank, u1.Id, u1.Reputation, u1.EmailHash, u1.LastAccessDate, (SELECT COUNT(*) FROM Users AS u2 WHERE u2.EmailHash = u1.EmailHash) AS Accounts FROM Users AS u1 WHERE NOT u1.EmailHash IS NULL) AS email WHERE Accounts > 0 AND Rank = 1 ORDER BY Accounts DESC, Reputation DESC, LastAccessDate DESC
|
### Instruction:
how many days have passed since patient 97733 last received a laboratory test of albumin in this 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 = 'albumin') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97733 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
how many people had been diagnosed with dis plas protein met nec until 2104?
### Response:
|
SELECT COUNT(DISTINCT 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 = 'dis plas protein met nec') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104')
|
### Instruction:
when did patient 97330 first had the maximum value of sodium since 03/2102?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97330) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'sodium') AND STRFTIME('%y-%m', labevents.charttime) >= '2102-03' ORDER BY labevents.valuenum DESC, labevents.charttime LIMIT 1
|
### Instruction:
Find my comments with link to them.
### Response:
|
SELECT *, 'http://stackoverflow.com/questions/' + CAST(PostAnswers.ParentId AS TEXT(20)) + '/title/' + CAST(Comments.PostId AS TEXT(20)) + '?noredirect=1#comment' + CAST(Comments.Id AS TEXT(20)) + '_' + CAST(Comments.PostId AS TEXT(20)) FROM Comments LEFT OUTER JOIN Posts AS PostAnswers ON Comments.PostId = PostAnswers.Id WHERE Comments.UserId = '##UserId##' ORDER BY Comments.Score DESC
|
### Instruction:
Next Summer after 21:00 A.M. what upper level electives are available ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course_offering.start_time > '21:00' 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 = 'Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2017
|
### Instruction:
What are the PreMajor or MDE courses offered in the Fall term ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number, program_course.category FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND program_course.category IN ('PreMajor', 'MDE') AND program_course.course_id = course.course_id AND semester.semester = 'Fall' AND semester.semester_id = course_offering.semester AND semester.year = 2016 GROUP BY course.department, course.number
|
### Instruction:
have any microbiological tests been done on patient 031-3355's blood, venipuncture in the first hospital visit?
### Response:
|
SELECT COUNT(*) 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 NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND microlab.culturesite = 'blood, venipuncture'
|
### 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 job_id and the sum of employee_id , and group by attribute job_id in a bar chart, and show in descending by the bar.
### Response:
|
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY JOB_ID DESC
|
### Instruction:
Does GREEKMOD 201 meet in the morning ?
### Response:
|
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course_offering.start_time < '12:00:00' AND course_offering.start_time >= '08:00:00' AND course.course_id = course_offering.course_id AND course.department = 'GREEKMOD' AND course.number = 201 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
count the number of times patient 1815 had a other brain dx procedure when they came to the hospital last time.
### 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 brain dx procedure') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1815 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)
|
### Instruction:
Will SM 217 be offered every semester ?
### 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 = 'SM' AND COURSEalias0.number = 217 AND SEMESTERalias1.semester_id = COURSE_OFFERINGalias0.semester)
|
### Instruction:
what was the organism name found in the last bile test of patient 7107 since 07/2105?
### Response:
|
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7107) AND microbiologyevents.spec_type_desc = 'bile' AND NOT microbiologyevents.org_name IS NULL AND STRFTIME('%y-%m', microbiologyevents.charttime) >= '2105-07' ORDER BY microbiologyevents.charttime DESC LIMIT 1
|
### Instruction:
among those with age 30s during this year, what are the top four most frequent lab tests?
### Response:
|
SELECT t1.labname FROM (SELECT lab.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 30 AND 39) AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 4
|
### Instruction:
Are there morning classes for STDABRD 255 ?
### Response:
|
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course_offering.start_time < '12:00:00' AND course_offering.start_time >= '08:00:00' AND course.course_id = course_offering.course_id AND course.department = 'STDABRD' AND course.number = 255 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
what is patient 61339's last output until 524 days ago?
### 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 = 61339)) AND DATETIME(outputevents.charttime) <= DATETIME(CURRENT_TIME(), '-524 day') ORDER BY outputevents.charttime DESC LIMIT 1)
|
### Instruction:
tell me about the top three most common procedures of patients of age 50s until 2 years ago?
### 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) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
has patient 013-33898 received a procedure of antihyperlipidemic agent - fenofibrate in 2105?
### 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-33898')) AND treatment.treatmentname = 'antihyperlipidemic agent - fenofibrate' AND STRFTIME('%y', treatment.treatmenttime) = '2105'
|
### Instruction:
Upvoted questions where all answers are downvoted.
### Response:
|
WITH cte AS (SELECT DISTINCT q.Id AS "post_link", COUNT(p.Id) OVER (PARTITION BY q.Id) AS "upvotedanswercount", COUNT(a.Id) OVER (PARTITION BY q.Id) AS totalAnswers, q.Score FROM Posts AS q LEFT JOIN Posts AS p ON q.Id = p.ParentId AND p.Score >= 0 INNER JOIN Posts AS a ON a.ParentId = q.Id WHERE q.Score >= 1) SELECT * FROM cte WHERE upvotedanswercount = 0 ORDER BY totalAnswers DESC
|
### Instruction:
have diagnosed patient 030-34260 with s/p knee surgery - replacement during their first hospital encounter?
### 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 = '030-34260' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND diagnosis.diagnosisname = 's/p knee surgery - replacement'
|
### Instruction:
T-SQL example: find url w/ specific extension within a string. Finds a URL in a string based on the extension... Find the extension first (ie, 'GIF'), and then look in reverse for the prefix (ie, 'HTTP')... This way it will skip any prefixes from previous URL's in the string.
### Response:
|
SELECT STR_POSITION(@body, @strEnd) + LENGTH(@strStart) - (STR_POSITION(REVERSE(LEFT(@body, STR_POSITION(@body, @strEnd) + LENGTH(@strStart) - 1)), REVERSE(@strStart)) + LENGTH(@strStart) - 1)
|
### Instruction:
how many days has passed since the last time patient 032-9230 got a procedure on this hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '032-9230' 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, find hire_date and the sum of employee_id bin hire_date by time, and visualize them by a bar chart, rank total number from low to high order.
### Response:
|
SELECT HIRE_DATE, SUM(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY SUM(EMPLOYEE_ID)
|
### Instruction:
what procedure did patient 54825 receive the first time when they visited the hospital last time.
### 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 = 54825 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY procedures_icd.charttime LIMIT 1)
|
### Instruction:
has there been any microbiological test performed on patient 031-16123's nasopharynx until 2104?
### Response:
|
SELECT COUNT(*) FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-16123')) AND microlab.culturesite = 'nasopharynx' AND STRFTIME('%y', microlab.culturetakentime) <= '2104'
|
### Instruction:
When will I have the opportunity to take Business Systems Consulting again ?
### Response:
|
SELECT DISTINCT semester.semester, semester.year FROM semester INNER JOIN course_offering ON semester.semester_id = course_offering.semester INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.name LIKE '%Business Systems Consulting%' AND semester.semester_id > (SELECT SEMESTERalias1.semester_id FROM semester AS SEMESTERalias1 WHERE SEMESTERalias1.semester = 'WN' AND SEMESTERalias1.year = 2016)
|
### Instruction:
HTTP links (instead of HTTPS) for isfdb.org.
### Response:
|
SELECT p.CreationDate, t.TagName, p.Id AS "post_link" FROM Posts AS p JOIN Tags AS t ON ((p.PostTypeId = 4 AND t.ExcerptPostId = p.Id) OR (p.PostTypeId = 5 AND t.WikiPostId = p.Id)) WHERE p.PostTypeId IN (4, 5) AND p.Body LIKE '%http://%' AND NOT p.Body LIKE '%http://isfdb.org%' AND NOT p.Body LIKE '%http://www.isfdb.org%' ORDER BY p.CreationDate DESC
|
### Instruction:
Answers for a certain tag (by year).
### Response:
|
SELECT a.Id AS "post_link", a.Id, q.Title, a.CreationDate, a.Score, q.ViewCount AS "views", CASE WHEN a.Id = q.AcceptedAnswerId THEN 1 ELSE 0 END AS Accepted, q.Tags FROM Posts AS a LEFT JOIN Posts AS q ON q.Id = a.ParentId WHERE a.PostTypeId = 2 AND a.OwnerUserId = '##UserId##' AND q.Tags LIKE '%<##Tag##>%' AND YEAR(a.CreationDate) = '##Year##' ORDER BY a.CreationDate DESC
|
### Instruction:
Users with at least 1K reputation and 'Civic Duty', Deputy' and 'Sheriff' badges.
### Response:
|
SELECT Id AS "user_link", Reputation, LastAccessDate FROM Users WHERE Reputation >= 1000 AND EXISTS(SELECT Id FROM Badges AS b WHERE b.UserId = Users.Id AND b.Name = 'Civic Duty') AND EXISTS(SELECT Id FROM Badges AS b WHERE b.UserId = Users.Id AND b.Name = 'Deputy') AND EXISTS(SELECT Id FROM Badges AS b WHERE b.UserId = Users.Id AND b.Name = 'Sheriff') ORDER BY LastAccessDate DESC
|
### Instruction:
Ability To Filter Posts Based On User's Last Seen Status. http://meta.stackoverflow.com/questions/328374/ability-to-filter-posts-based-on-users-last-seen-status
### Response:
|
SELECT p.Id AS "post_link", u.LastAccessDate, u.Id AS "user_link" FROM Posts AS p INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE p.PostTypeId = 1 AND u.LastAccessDate < DATEADD(yy, -1, GETDATE()) AND p.Tags LIKE '%<haskell>%' AND NOT ClosedDate IS NULL ORDER BY u.LastAccessDate DESC
|
### Instruction:
what were the three most commonly ordered lab tests during this year for patients in the age 20s?
### Response:
|
SELECT t1.labname FROM (SELECT lab.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 20 AND 29) AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
what is the maximum total cost of the hospital that includes the laboratory cd8 cells, percent test the last year?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'cd8 cells, percent')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.hadm_id) AS t1
|
### Instruction:
Does the university offer MDE or PreMajor classes for the Summer term ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number, program_course.category FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND program_course.category IN ('MDE', 'PreMajor') AND program_course.course_id = course.course_id AND semester.semester = 'Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2016 GROUP BY course.department, course.number
|
### 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, return a bar chart about the distribution of job_id and the average of employee_id , and group by attribute job_id, and list by the x-axis in desc.
### 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 JOB_ID DESC
|
### Instruction:
how many days has passed since patient 739 last received a lab test for hematocrit in 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 = 'hematocrit') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 739 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime 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, a bar chart shows the distribution of job_id and the sum of manager_id , and group by attribute job_id, and display by the y axis in desc please.
### Response:
|
SELECT JOB_ID, SUM(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(MANAGER_ID) DESC
|
### Instruction:
Of the classes , which can be taken as Other next semester ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program, program_course, semester WHERE course.course_id = course_offering.course_id AND program_course.category LIKE '%Other%' AND program_course.course_id = course.course_id AND program.name LIKE '%CS-LSA%' AND program.program_id = program_course.program_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
how many days since patient 030-52327 received a procedure for the first time on this hospital visit?
### 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 = '030-52327' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
what is the amount of urine out ureteral stent #2 output patient 44625 has?
### 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 = 44625)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'urine out ureteral stent #2' AND d_items.linksto = 'outputevents')
|
### Instruction:
For a course in which a student minoring in CMPLXSYS has gotten a C+ , which professor has taught it ?
### Response:
|
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN student_record ON student_record.offering_id = offering_instructor.offering_id INNER JOIN student ON student.student_id = student_record.student_id WHERE (student_record.grade LIKE '%C+%' OR student_record.grade LIKE '%C+%') AND student.minor = 'CMPLXSYS'
|
### Instruction:
what was the number of patients receiving excise bone for gft nec since 2101?
### 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 = 'excise bone for gft nec') AND STRFTIME('%y', procedures_icd.charttime) >= '2101')
|
### Instruction:
Who is teaching Field Geology Project ?
### Response:
|
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN course ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.name LIKE '%Field Geology Project%' AND semester.semester = 'WN' AND semester.year = 2016
|
### 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 hire_date bin hire_date by time, I want to order from high to low by the Y-axis.
### Response:
|
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY AVG(MANAGER_ID) DESC
|
### Instruction:
in 10/2101, what organism was found in patient 23061's first urine test?
### Response:
|
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23061) AND microbiologyevents.spec_type_desc = 'urine' AND NOT microbiologyevents.org_name IS NULL AND STRFTIME('%y-%m', microbiologyevents.charttime) = '2101-10' ORDER BY microbiologyevents.charttime LIMIT 1
|
### Instruction:
Find all Italian restaurant in the Meadowood neighborhood of Madison
### Response:
|
SELECT business.name FROM business, category AS CATEGORY_0, category AS CATEGORY_1, neighborhood WHERE business.city = 'Madison' AND CATEGORY_0.business_id = business.business_id AND CATEGORY_0.category_name = 'Italian' AND CATEGORY_1.business_id = business.business_id AND CATEGORY_1.category_name = 'restaurant' AND neighborhood.business_id = business.business_id AND neighborhood.neighborhood_name = 'Meadowood'
|
### Instruction:
Most Popular Tag By Location By Year Ordered By Most PostTags.
### Response:
|
SELECT Posts.Id AS "post_link", Posts.CreationDate, Posts.Title, Posts.Body, Posts.Tags FROM Posts, Users WHERE Posts.OwnerUserId = Users.Id AND (UPPER(Location) LIKE UPPER('%CAMEROON%') OR Location LIKE '%cameroon%' OR Location LIKE '%Cameroon%' OR Location LIKE '%Cameroun%' OR LOWER(Location) LIKE '%cameroun%' OR UPPER(Location) LIKE '%CAMEROUN%') AND (Posts.Tags IS NULL) ORDER BY Posts.CreationDate
|
### Instruction:
list patient ids of patients diagnosed with hypothermia 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 = 'hypothermia') AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
|
### Instruction:
List of users with their gold badge counts and number of posts.
### Response:
|
SELECT u.DisplayName, Posts.OwnerUserId AS UserId, BadgeCount, COUNT(Posts.Id) AS PostsCount FROM Posts JOIN Users AS u ON u.Id = Posts.OwnerUserId JOIN (SELECT Badges.UserId AS UserId, COUNT(Badges.Id) AS BadgeCount FROM Badges WHERE Badges.Class = 1 GROUP BY Badges.UserId) AS B ON Posts.OwnerUserId = B.UserId GROUP BY u.DisplayName, Posts.OwnerUserId, B.BadgeCount ORDER BY b.badgecount DESC LIMIT 10
|
### Instruction:
how many hours has it been since first time patient 009-5001 had a procedure on this hospital visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-5001' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
papers by authors Richard Ladner and Linda Shapiro
### Response:
|
SELECT DISTINCT WRITES_0.paperid FROM author AS AUTHOR_0, author AS AUTHOR_1, writes AS WRITES_0, writes AS WRITES_1 WHERE AUTHOR_0.authorname = 'Richard Ladner' AND AUTHOR_1.authorname = 'Linda Shapiro' AND WRITES_0.authorid = AUTHOR_0.authorid AND WRITES_1.authorid = AUTHOR_1.authorid AND WRITES_1.paperid = WRITES_0.paperid
|
### Instruction:
calculate how many times until 2104 patient 005-11182 has received the systemic antibiotics - quinolone procedure.
### Response:
|
SELECT COUNT(*) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-11182')) AND treatment.treatmentname = 'systemic antibiotics - quinolone' AND STRFTIME('%y', treatment.treatmenttime) <= '2104'
|
### Instruction:
The birth of good users.
### Response:
|
WITH FirstPosts AS (SELECT OwnerUserId AS SEUser, MIN(Id) AS Post FROM Posts WHERE PostTypeId = 1 OR PostTypeId = 2 GROUP BY OwnerUserId) SELECT FirstPosts.SEUser AS "user_link", FirstPosts.Post AS "post_link", 'post_type' = CASE PostTypeId WHEN 1 THEN 'Question' WHEN 2 THEN 'Answer' ELSE '???' END, Reputation FROM FirstPosts JOIN Users ON FirstPosts.SEUser = Users.Id JOIN Posts ON FirstPosts.Post = Posts.Id ORDER BY PostTypeId DESC LIMIT 500
|
### Instruction:
severe uncontrolled arterial hypertension ( hypertension defined as blood pressure 180 / 110 mm hg ( systolic bp > 180 mm hg and / or diastolic bp > 100 mm hg ) on one single reliable measurement during current admission prior to study enrolment
### Response:
|
SELECT * FROM table_test_16 WHERE severe_uncontrolled_arterial_hypertension = 1 OR (hypertension = 1 OR (systolic_blood_pressure_sbp > 180 OR diastolic_blood_pressure_dbp > 100))
|
### Instruction:
had patient 013-28507 excreted any output amt-blake drain a during their current hospital 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 = '013-28507' AND patient.hospitaldischargetime IS NULL)) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output amt-blake drain a'
|
### Instruction:
Users by number of answers they posted.
### Response:
|
SELECT COALESCE('site://users/' + CAST(a.OwnerUserId AS TEXT) + '|' + u.DisplayName, a.OwnerDisplayName) AS UserLink, COUNT(a.Id) AS QCount, u.Reputation FROM Posts AS a LEFT JOIN Users AS u ON u.Id = a.OwnerUserId WHERE a.PostTypeId = 2 AND u.Reputation >= 5000 GROUP BY a.OwnerUserId, a.OwnerDisplayName, u.DisplayName, u.Reputation HAVING 10 <= COUNT(a.Id) ORDER BY COUNT(a.Id) DESC
|
### Instruction:
calculate the number of patients that had received a anticonvulsants - valproate procedure two times the last year.
### 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 = 'anticonvulsants - valproate' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 = 2
|
### Instruction:
how many days have elapsed since patient 1114 has first received a free calcium lab test on this 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 = 'free calcium') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1114 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
Top 1000 most viewed question in a given tag per year.
### Response:
|
SELECT YEAR(p.CreationDate) AS Year, p.Id AS "post_link", p.ViewCount FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE p.PostTypeId = 1 AND t.TagName = '##TagName##' GROUP BY YEAR(p.CreationDate), p.Id, p.ViewCount ORDER BY ROW_NUMBER() OVER (PARTITION BY YEAR(p.CreationDate) ORDER BY p.ViewCount DESC) LIMIT 1000
|
### Instruction:
what was the name of the drug prescribed to patient 7112, two or more times during this month?
### Response:
|
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7112) AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 >= 2
|
### 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 sum of department_id , and group by attribute job_id, list y axis from low to high order.
### Response:
|
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(DEPARTMENT_ID)
|
### Instruction:
Which Model has a GCM (kg) Technical Capacity of 35000, a GVM (kg) Technical Capacity of 16000, and Cummins Interact 6.0-euro III (turbo intercooler) for the Engine?
### Response:
|
SELECT "Model" FROM table_54073 WHERE "GCM (kg) Technical Capacity" = '35000' AND "GVM (kg) Technical Capacity" = '16000' AND "Engine make/Capacity" = 'cummins interact 6.0-euro iii (turbo intercooler)'
|
### Instruction:
hey what was patient 028-45581's minimum troponin - i value in 08/2102?
### 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 = '028-45581')) AND lab.labname = 'troponin - i' AND STRFTIME('%y-%m', lab.labresulttime) = '2102-08'
|
### Instruction:
what is the last value of the phosphate lab test of patient 83062 in this month?
### Response:
|
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 83062) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'phosphate') AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
what was patient 013-9305 last height in 08/last year?
### Response:
|
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-9305') 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) = '08' ORDER BY patient.unitadmittime DESC LIMIT 1
|
### Instruction:
when did patient 14203 first had the minimum magnesium level until 02/2105?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14203) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'magnesium') AND STRFTIME('%y-%m', labevents.charttime) <= '2105-02' ORDER BY labevents.valuenum, labevents.charttime LIMIT 1
|
### Instruction:
what was the last value of the calculated total co2 lab test for patient 56201 until 09/2103?
### Response:
|
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 56201) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'calculated total co2') AND STRFTIME('%y-%m', labevents.charttime) <= '2103-09' ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
What is the lowest group number that has a Fraction less than 0.000748, a Half-Life of 55.72 and a Decay Constant larger than 0.012400000000000001?
### Response:
|
SELECT MIN("Group") FROM table_68764 WHERE "Fraction" < '0.000748' AND "Half-Life (s)" = '55.72' AND "Decay Constant (s \u22121 )" > '0.012400000000000001'
|
### Instruction:
when was the last time that patient 021-80293 had a minimum heartrate on the current icu 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 = '021-80293') AND patient.unitdischargetime IS NULL) AND NOT vitalperiodic.heartrate IS NULL ORDER BY vitalperiodic.heartrate, vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
For the Fall and Winter , what upper-level electives are offered ?
### 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 semester ON semester.semester_id = course_offering.semester INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (semester.semester = 'FA' OR semester.semester = 'WN') AND course.department = 'EECS' AND program_course.category LIKE '%ULCS%' AND semester.year = 2016
|
### 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, could you order x axis in desc order?
### 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 JOB_ID DESC
|
### Instruction:
until 4 years ago what were the five most commonly ordered drugs for patients of age 40s?
### Response:
|
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 40 AND 49) AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
what is the maximum hospital cost that would involve a vancomycin - trough lab test since 2103?
### 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 lab.patientunitstayid FROM lab WHERE lab.labname = 'vancomycin - trough')) AND STRFTIME('%y', cost.chargetime) >= '2103' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
is there any microbiological test result since 2104 for patient 031-16123's nasopharynx?
### Response:
|
SELECT COUNT(*) FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-16123')) AND microlab.culturesite = 'nasopharynx' AND STRFTIME('%y', microlab.culturetakentime) >= '2104'
|
### Instruction:
how many patients had been diagnosed with hydroureter until 2 years ago?
### Response:
|
SELECT COUNT(DISTINCT 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 = 'hydroureter') AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-2 year'))
|
### 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, return a bar chart about the distribution of job_id and the average of salary , and group by attribute job_id, and could you display by the y axis in ascending?
### Response:
|
SELECT JOB_ID, AVG(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(SALARY)
|
### Instruction:
how much is the minimum total cost of a hospital that involves a drug called albumin human in 2104?
### 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 medication.patientunitstayid FROM medication WHERE medication.drugname = 'albumin human')) AND STRFTIME('%y', cost.chargetime) = '2104' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
what was the name of the drug that was last prescribed to patient 022-6959 in the current hospital visit via the infiltration 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 = '022-6959' AND patient.hospitaldischargetime IS NULL)) AND medication.routeadmin = 'infiltration' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
what is the average value of osmolality, measured in patient 40059's body during this month?
### Response:
|
SELECT AVG(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 40059) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'osmolality, measured') AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
|
### Instruction:
when was the last time patient 15986 got a lab test in this month for lactate?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'lactate') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15986) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
Any morning classes for ARMENIAN 171 ?
### Response:
|
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course_offering.start_time < '12:00:00' AND course_offering.start_time >= '08:00:00' AND course.course_id = course_offering.course_id AND course.department = 'ARMENIAN' AND course.number = 171 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
when patient 031-3507 received a microbiology test for the last time on their first hospital encounter?
### 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-3507' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
what was the name of the drug, which patient 20801 had been prescribed two times until 09/2105?
### Response:
|
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20801) AND STRFTIME('%y-%m', prescriptions.startdate) <= '2105-09' GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
|
### Instruction:
Number of Later Posts Per User by First Tag.
### Response:
|
WITH FirstQuestionTags AS (SELECT p.OwnerUserId, p.ClosedDate, pt.TagId, RANK() OVER (PARTITION BY p.OwnerUserId ORDER BY p.Id) AS "rank" FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id), FirstTagMatches AS (SELECT ft.OwnerUserId, ft.ClosedDate FROM FirstQuestionTags AS ft INNER JOIN Tags AS t ON t.Id = ft.TagId WHERE ft.Rank = 1 AND t.TagName LIKE '##TagName:string##' + '%') SELECT * FROM FirstTagMatches
|
### Instruction:
what was patient 010-3286's last value of potassium since 04/2102?
### 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 = '010-3286')) AND lab.labname = 'potassium' AND STRFTIME('%y-%m', lab.labresulttime) >= '2102-04' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
Find High-Voted Questions with No Accepted Answers in Last Month.
### Response:
|
SELECT Id AS "post_link", Score, ViewCount AS Views, AnswerCount AS Answers, (SELECT Score FROM Posts AS b WHERE PostTypeId = 2 AND b.ParentId = a.Id ORDER BY Score DESC LIMIT 1) AS TopAnswerScore FROM Posts AS a WHERE NOT Tags LIKE '%' + 'story-identification' + '%' AND AcceptedAnswerId IS NULL AND PostTypeId = 1 AND CreationDate > CURRENT_TIMESTAMP() - 30 AND ClosedDate IS NULL ORDER BY AnswerCount, Score DESC LIMIT 100
|
### Instruction:
when was the last time for a medication prescribed to patient 028-61375 until 53 months ago?
### Response:
|
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-61375')) AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-53 month') ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
tell me the average hospital cost when there is coronary artery disease 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 diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'coronary artery disease')) AND STRFTIME('%y', cost.chargetime) <= '2104' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
what is the maximum hospital cost when it involves pneumonia - opportunistic until 2104?
### 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 = 'pneumonia - opportunistic')) AND STRFTIME('%y', cost.chargetime) <= '2104' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
how many patients until 1 year ago had received a routine chest x-ray procedure?
### 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 = 'routine chest x-ray') AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year'))
|
### Instruction:
After 17:00 A.M. next Spring what upper level electives are available ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course_offering.start_time > '17:00' 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 = 'Spring' AND semester.semester_id = course_offering.semester AND semester.year = 2017
|
### Instruction:
was any of the organisms found in patient 18877's last bronchoalveolar lavage test in the first hospital visit?
### Response:
|
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 18877 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND microbiologyevents.spec_type_desc = 'bronchoalveolar lavage' AND NOT microbiologyevents.org_name IS NULL ORDER BY microbiologyevents.charttime 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, return a bar chart about the distribution of hire_date and the amount of hire_date bin hire_date by weekday, and I want to order in descending by the y axis.
### Response:
|
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY COUNT(HIRE_DATE) DESC
|
### Instruction:
Is there another person besides Prof. Etzion that teaches Leading Non-Profit Organizations ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number, instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.name LIKE '%Leading Non-Profit Organizations%' AND NOT instructor.name LIKE '%Etzion%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
|
### Instruction:
Questions with most dupes attached (WIP).
### Response:
|
SELECT COUNT(p.Id) AS "close_count", ph.Comment AS "reason_id", MAX(p.Id) AS "example_post", MAX(p.Id) AS "post_link" FROM Posts AS p INNER JOIN PostHistory AS ph ON p.Id = ph.PostId INNER JOIN PostHistoryTypes AS pht ON ph.PostHistoryTypeId = pht.Id WHERE NOT p.ClosedDate IS NULL AND pht.Name = 'Post Closed' AND (ph.Comment = '1' OR ph.Comment = '101') GROUP BY ph.Comment ORDER BY 'close_count' DESC
|
### Instruction:
what procedure did patient 10624 undergo for the first time on their first hospital encounter?
### 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 = 10624 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) ORDER BY procedures_icd.charttime LIMIT 1)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.