instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: how many hours has it been since last time patient 99883 was prescribed clotrimazole during this hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 99883 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'clotrimazole' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: What Cultural Studies of Central , Eastern , and Southern Europe classes fill the MDE requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (area.area LIKE '%Cultural Studies of Central , Eastern , and Southern Europe%' OR course.description LIKE '%Cultural Studies of Central , Eastern , and Southern Europe%' OR course.name LIKE '%Cultural Studies of Central , Eastern , and Southern Europe%') AND program_course.category LIKE '%MDE%'
### Instruction: count the number of times patient 002-39247 has been tested for creatinine in labs since 51 months ago. ### Response:
SELECT COUNT(*) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-39247')) AND lab.labname = 'creatinine' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-51 month')
### Instruction: Search question and most voted answer. ### Response:
SELECT p.Title, p.Id, p.Score, a.Score AS "post_link", a.Score AS "Accepted Score", u.DisplayName AS "Asker", au.DisplayName AS "Answerer" FROM Posts AS p JOIN Posts AS a ON p.AcceptedAnswerId = a.Id JOIN Users AS u ON p.OwnerUserId = u.Id JOIN Users AS au ON a.OwnerUserId = au.Id WHERE p.PostTypeId = 1 AND p.Score >= 25 AND NOT p.AcceptedAnswerId IS NULL ORDER BY p.Score DESC
### Instruction: Show the number of students who are living in a dorm with a TV Lounge and group by first name in a bar chart, display from low to high by the bar please. ### Response:
SELECT Fname, COUNT(Fname) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM Has_amenity AS T3 JOIN Dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge') GROUP BY Fname ORDER BY Fname
### Instruction: tell me what's the total urine out foley output of patient 90019. ### 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 = 90019)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'urine out foley' AND d_items.linksto = 'outputevents')
### Instruction: Find answers by a given user (with links). ### Response:
SELECT q.Id AS "Q ID", a.Id AS "A ID", q.CreationDate AS "Q Date", a.CreationDate AS "A Date", q.Score AS "Q Score", a.Score AS "A Score", q.ClosedDate AS "Question Closed Date", q.Id AS "post_link" FROM Posts AS a JOIN Posts AS q ON a.ParentId = q.Id JOIN Users AS u ON q.OwnerUserId = u.Id WHERE a.OwnerUserId = '##UserId:int##' ORDER BY a.Score DESC
### 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 admission year is less than 2197? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "NEOPLASM OF UNCERTAIN BEHAVIOR OF OTHER LYMPHATIC AND HEMATOPOIETIC TISSUES\BONE MARROW TRANSPLANT" AND demographic.admityear < "2197"
### Instruction: Is 413 being taught by anyone else other than Prof. Gladys Saborio ? ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 413 AND NOT instructor.name LIKE '%Gladys Saborio%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: What is the least time-consuming class I can take to fulfill the ULCS requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload, program_course.workload FROM course, program_course WHERE program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM program_course AS PROGRAM_COURSEalias1 WHERE PROGRAM_COURSEalias1.category LIKE '%ULCS%')
### Instruction: did patient 013-28507 receive any tests for crp in this year? ### Response:
SELECT COUNT(*) > 0 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-28507')) AND lab.labname = 'crp' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: what are the minimum yearly number of patients diagnosed with reflux esophagitis? ### Response:
SELECT MIN(t1.c1) FROM (SELECT COUNT(DISTINCT diagnoses_icd.hadm_id) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'reflux esophagitis') GROUP BY STRFTIME('%y', diagnoses_icd.charttime)) AS t1
### Instruction: what was the last time patient 3911 got the rapid respiratory viral antigen test microbiology test on the first hospital visit? ### Response:
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3911 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND microbiologyevents.spec_type_desc = 'rapid respiratory viral antigen test' ORDER BY microbiologyevents.charttime DESC LIMIT 1
### Instruction: Top answerers in the given tag (including deleted users, only non-CW). ### Response:
SELECT a.OwnerUserId AS "user_link", a.OwnerDisplayName, SUM(a.Score) AS "total_score", COUNT(a.Id) AS "num_answers" FROM Posts AS a JOIN Posts AS q ON a.ParentId = q.Id WHERE a.PostTypeId = 2 AND q.Tags LIKE '%<##tagName##>%' AND a.CommunityOwnedDate IS NULL GROUP BY a.OwnerUserId, a.OwnerDisplayName ORDER BY SUM(a.Score) DESC LIMIT 100
### Instruction: what is the average hospital cost that would involve a creatinine, pleural lab test in 2104? ### Response:
SELECT AVG(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 = 'creatinine, pleural')) AND STRFTIME('%y', cost.chargetime) = '2104' GROUP BY cost.hadm_id) AS t1
### Instruction: WHAT WAS THE AMOUNT OF CARBON DIOXIDE EMISSIONS IN 2006 IN THE COUNTRY WHOSE CO2 EMISSIONS (TONS PER PERSON) REACHED 1.4 IN 2OO7? ### Response:
SELECT carbon_dioxide_emissions_per_year__10_6_tons___2006_ FROM table_11251601_2 WHERE carbon_dioxide_emissions_per_year__tons_per_person___2007_ = "1.4"
### Instruction: what is the yearly minimum of patient 006-14121's weight since 05/2105? ### Response:
SELECT MIN(patient.admissionweight) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-14121') AND NOT patient.admissionweight IS NULL AND STRFTIME('%y-%m', patient.unitadmittime) >= '2105-05' GROUP BY STRFTIME('%y', patient.unitadmittime)
### Instruction: what was the name of the lab test that the previous month patient 73693 received for the last time? ### 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 = 73693) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY labevents.charttime DESC LIMIT 1)
### Instruction: For Fall 2017 , is there a 1 -credit upper level class ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND course.credits = 1 AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Fall' AND semester.semester_id = course_offering.semester AND semester.year = 2017
### Instruction: In the Fall and Winter terms , how many 200 -level classes are being offered ? ### Response:
SELECT COUNT(DISTINCT course.course_id, semester.semester) FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'department0' AND course.number BETWEEN 200 AND 200 + 100 AND semester.semester IN ('FA', 'WN') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: For a CS major , what classes are available this Winter that would count towards that ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program, program_course, semester WHERE program_course.course_id = course.course_id AND program_course.course_id = course.course_id AND program.name LIKE '%CS%' AND program.program_id = program_course.program_id AND semester.semester = 'Winter' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: had sepsis been diagnosed with patient 015-33415 until 2104? ### 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 = '015-33415')) AND diagnosis.diagnosisname = 'sepsis' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2104'
### Instruction: Answers close to the Necromancer badge. All your answers that were posted at least 60 days after the question was posted, with a score of 4 or lower. When any of these reach a score of 5, they should earn you a Necromancer silver badge. ### Response:
SELECT a.Id AS "post_link", a.Score FROM Posts AS q INNER JOIN Posts AS a ON q.Id = a.ParentId WHERE a.PostTypeId = 2 AND a.Score <= 4 AND DATEDIFF(d, q.CreationDate, creationdate) >= 60 ORDER BY a.Score DESC
### Instruction: What's the fed tax that has a total tax greater than 33.2, a minimum sales tax less than 41.01 and in Vancouver, BC? ### Response:
SELECT AVG("Federal excise tax ( CAD\u00a2 / L )") FROM table_48271 WHERE "Total excise tax (CAD\u00a2/L)" > '33.2' AND "Government" = 'vancouver, bc' AND "Minimum tax incl. sales taxes (CAD\u00a2/L)" < '41.01'
### Instruction: what procedure did patient 017-27817 until 2 years ago receive for the last time? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-27817')) AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-2 year') ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of hire_date and the average of department_id bin hire_date by time in a bar chart, and display in descending by the the average of department id please. ### Response:
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY AVG(DEPARTMENT_ID) DESC
### Instruction: What are the album titles for albums containing both 'Reggae' and 'Rock' genre tracks? ### Response:
SELECT T1.title FROM album AS T1 JOIN track AS T2 ON T1.albumid = T2.albumid JOIN genre AS T3 ON T2.genreid = T3.genreid WHERE T3.name = 'Reggae' INTERSECT SELECT T1.title FROM album AS T1 JOIN track AS T2 ON T1.albumid = T2.albumid JOIN genre AS T3 ON T2.genreid = T3.genreid WHERE T3.name = 'Rock'
### Instruction: What are the upper-level MUSTHTRE classes being offered this Summer ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND course.department = 'MUSTHTRE' 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 = 2016
### Instruction: did patient 006-10390 underwent a antiemetic - serotonin antagonist in the current hospital visit? ### 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 = '006-10390' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'antiemetic - serotonin antagonist'
### Instruction: what's the first diagnosis patient 006-1629 got on the last hospital encounter? ### Response:
SELECT diagnosis.diagnosisname FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-1629' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: what was patient 030-56105 first diagnosed with in their last hospital visit? ### Response:
SELECT diagnosis.diagnosisname FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-56105' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: what are the top four most frequent lab tests among the patients that are 50s in 2105? ### 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 50 AND 59) AND STRFTIME('%y', lab.labresulttime) = '2105' GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 4
### Instruction: How many courses for each course description? Show me a bar chart, list in asc by the X-axis. ### Response:
SELECT CRS_DESCRIPTION, COUNT(CRS_DESCRIPTION) 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 ORDER BY CRS_DESCRIPTION
### Instruction: What courses offered in Fall or Winter meet the MDE requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester 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_offering.course_id WHERE program_course.category LIKE '%MDE%' AND semester.semester IN ('FA', 'WN') AND semester.year = 2016
### Instruction: has vancomycin hcl, phenylephrine, or d5w (excel bag) been prescribed for patient 13806 until 2102? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13806) AND prescriptions.drug IN ('vancomycin hcl', 'phenylephrine', 'd5w (excel bag)') AND STRFTIME('%y', prescriptions.startdate) <= '2102'
### Instruction: what's the maximum cost of a hospital with hydromorphone 1 mg/1 ml syr? ### Response:
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT medication.patientunitstayid FROM medication WHERE medication.drugname = 'hydromorphone 1 mg/1 ml syr')) GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: Do any 400 -level classes occur in the Fall or Winter term ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number BETWEEN 400 AND 400 + 100 AND semester.semester IN ('FA', 'WN') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: count the number of times patient 27703's rbc, csf test has been taken last month. ### Response:
SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'rbc, csf') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27703) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
### Instruction: calculate how many times patient 006-168146 has received antiviral therapy procedures since 2104. ### 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 = '006-168146')) AND treatment.treatmentname = 'antiviral therapy' AND STRFTIME('%y', treatment.treatmenttime) >= '2104'
### Instruction: casperOne's Top Answers by Tags. casperOne's answers aggregated by tag, where the number of answers per tag is greater than or equal to five. ### Response:
SELECT t.TagName, COUNT(t.Id) AS AnswersForTag FROM Posts AS q INNER JOIN PostTags AS pt ON pt.PostId = q.Id INNER JOIN Tags AS t ON t.Id = pt.TagId INNER JOIN Posts AS a ON a.ParentId = q.Id WHERE a.OwnerUserId = 68172 GROUP BY t.TagName HAVING COUNT(t.Id) >= 5 ORDER BY 2 DESC
### Instruction: Question States over Time (Percent). ### Response:
WITH Batches AS (SELECT DATEADD(mm, DATEPART(mm, Post.CreationDate) - 1, DATEADD(yy, DATEPART(yyyy, Post.CreationDate) - 1900, 0)) AS "date", COUNT(*) AS Total, SUM(CASE WHEN NOT Post.LastEditorUserId IS NULL THEN 1 ELSE 0 END) AS "edited" FROM Posts AS Post GROUP BY DATEPART(yyyy, Post.CreationDate), DATEPART(mm, Post.CreationDate)) SELECT 'date', Total, Edited FROM Batches ORDER BY Date
### Instruction: what is the number of patients whose primary disease is pneumonia;human immunodefiency virus;rule out tuberculosis and procedure short title is aortocor bypas-2 cor art? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "PNEUMONIA;HUMAN IMMUNODEFIENCY VIRUS;RULE OUT TUBERCULOSIS" AND procedures.short_title = "Aortocor bypas-2 cor art"
### Instruction: how many days is it since patient 27146 was first prescribed potassium chloride on their current hospital encounter? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27146 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'potassium chloride' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: what is the minimum total cost of the hospital, which includes the liver transplant status? ### Response:
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'liver transplant status')) GROUP BY cost.hadm_id) AS t1
### Instruction: How many 300 -level classes are being offered in Spring and Summer term ? ### Response:
SELECT COUNT(DISTINCT course.course_id, semester.semester) FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number BETWEEN 300 AND 300 + 100 AND semester.semester IN ('SP', 'SS', 'SU') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Comments asking 'where' in the 'electrical' tag. Looking for comments that match a given search term (default is 'where') on questions marked with a given tag (default is 'electrical'). ### Response:
WITH taggedQ AS (SELECT PostId FROM PostTags WHERE TagId = @tagid) SELECT Comments.PostId, Comments.PostId AS "post_link", Comments.Text FROM Comments INNER JOIN taggedQ ON Comments.PostId = taggedQ.PostId WHERE LOWER(Comments.Text) LIKE CONCAT('%', LOWER(@searchterm), '%') ORDER BY Comments.CreationDate
### Instruction: what is the number of patients whose diagnoses long title is acute glomerulonephritis with other specified pathological lesion in kidney and drug route is iv drip? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.long_title = "Acute glomerulonephritis with other specified pathological lesion in kidney" AND prescriptions.route = "IV DRIP"
### Instruction: how many days had it been since patient 76372 received her first acetaminophen prescription in the current hospital visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 76372 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'acetaminophen' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Your Posting Quality (Reputation per Posts). Enter your user ID and find out how much rep you earn per post ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "rank", Id AS "user_link", Id, Reputation, counts."#_posts", Reputation / counts."#_posts" AS "rep_per_post" FROM Users JOIN LATERAL (SELECT COUNT(*) FROM Posts WHERE Posts.OwnerUserId = Users.Id) AS counts("#_posts") WHERE counts."#_posts" > 0 ORDER BY 'rep_per_post' DESC LIMIT 2000
### Instruction: Are there upper elective classes next semester that do not meet on Friday ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course_offering.friday = 'N' AND course.course_id = course_offering.course_id AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: how many days has it been since patient 40707 has received the first prescription of d10w during their current hospital visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 40707 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'd10w' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Which ULCS requirement courses are available in the Fall or Winter ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester 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_offering.course_id WHERE program_course.category LIKE '%ULCS%' AND semester.semester IN ('FA', 'WN') AND semester.year = 2016
### Instruction: When Prof. Anne Greenberg teaches 663 are there classes on Friday ? ### 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.number = 663 AND course_offering.friday = 'N' AND instructor.name LIKE '%Anne Greenberg%'
### Instruction: what is the minimum number of patients diagnosed with acute copd exacerbation - with baseline hypercarbia yearly until 2103? ### Response:
SELECT MIN(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'acute copd exacerbation - with baseline hypercarbia' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2103' GROUP BY STRFTIME('%y', diagnosis.diagnosistime)) AS t1
### Instruction: Which tags used most with the entered tag. ### Response:
SELECT TagId, TagName, TagCount FROM (SELECT TOP(20) AS TagId, COUNT(TagId) AS TagCount FROM (SELECT TagId FROM (SELECT DISTINCT PostId AS PostId FROM PostTags WHERE TagId = (SELECT Id FROM Tags WHERE TagName = @TagName)) AS PostsWithTag JOIN PostTags AS AllPostTags ON PostsWithTag.PostId = AllPostTags.PostId) AS TagsUsed GROUP BY TagId ORDER BY TagCount DESC) AS TagsOrdered LEFT JOIN Tags ON Tags.Id = TagsOrdered.TagId ORDER BY TagCount DESC
### Instruction: how much is the maximum hospital bill that involves a total protein, urine lab test since 5 years ago? ### 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 = 'total protein, urine')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-5 year') GROUP BY cost.hadm_id) AS t1
### Instruction: Attrition: Reputation>10K Last post < 2012. ### Response:
SELECT u.DisplayName, u.Reputation, u.LastAccessDate, p.LastPost FROM Users AS u INNER JOIN (SELECT OwnerUserId, MAX(CreationDate) AS LastPost FROM Posts WHERE CreationDate < '2012-01-01' GROUP BY OwnerUserId) AS p ON u.Id = p.OwnerUserId WHERE Reputation > 10000 AND u.LastAccessDate < '2012-01-01' ORDER BY Reputation DESC LIMIT 40
### Instruction: oh what is the average value of -basos on patient 004-79017 since 6 months ago? ### Response:
SELECT AVG(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-79017')) AND lab.labname = '-basos' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-6 month')
### Instruction: what are the drugs that patient 013-30085 has an allergic reaction to this month? ### Response:
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-30085')) AND DATETIME(allergy.allergytime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: provide me the number of patients on succinylcholine prescription who have intervertebral disc disorder with myelopathy, unspecified region diagnoses. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.long_title = "Intervertebral disc disorder with myelopathy, unspecified region" AND prescriptions.drug = "Succinylcholine"
### Instruction: Users With the Highest Quality Posts (filter num posts). Enter the minimum number of posts that a user must have, and this will show the users who have the highest reputation per post in that group. ### Response:
SELECT Id AS "user_link", Reputation, Reputation * 1.0 / C.Cnt AS "rep_per_post" FROM Users AS U INNER JOIN (SELECT OwnerUserId, Cnt = COUNT(*) FROM Posts GROUP BY OwnerUserId HAVING COUNT(*) >= '##MinNumberOfPosts##') AS C ON U.Id = C.OwnerUserId ORDER BY 'rep_per_post' DESC
### Instruction: get me the drug that patient 8005 has been last prescribed in 03/last year. ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8005) AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', prescriptions.startdate) = '03' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: Select All Javascript Questions and Accepted answers. ### Response:
SELECT QPosts.ViewCount, QPosts.LastActivityDate, QPosts.Title, QPosts.Id, QPosts.Body, QPosts.AcceptedAnswerId AS "answer Id", APosts.Body FROM Posts AS QPosts, Posts AS APosts, PostTags WHERE (QPosts.Id = PostTags.PostId) AND (PostTags.TagId = 3) AND (QPosts.PostTypeId = 1) AND APosts.Id = QPosts.AcceptedAnswerId LIMIT 20000
### Instruction: What is the highest Amerindian (Hispanic/Non-Hispanic) value having a Black (Hispanic/Non-Hispanic) of 15.7 and White (Hispanic/Non-Hispanic) over 69.5? ### Response:
SELECT MAX(amerindian__both_hispanic_and_non_hispanic_) FROM table_name_67 WHERE black__both_hispanic_and_non_hispanic_ = 15.7 AND white__both_hispanic_and_non_hispanic_ > 69.5
### Instruction: The nth question (excluding closed questions). ### Response:
WITH ordered AS (SELECT ROW_NUMBER() OVER (ORDER BY CreationDate) AS rownumber, Id, CreationDate, Title, Score, OwnerUserId, Tags, ViewCount, AnswerCount, FavoriteCount FROM Posts AS q WHERE (PostTypeId = 1) AND (ClosedDate IS NULL)) SELECT rownumber, Id AS "post_link", CreationDate, Title, Score, OwnerUserId AS "user_link", Tags, ViewCount, AnswerCount, FavoriteCount FROM ordered WHERE rownumber = '##num##'
### Instruction: Post answer details for mchallnege. ### Response:
SELECT Q.Id, Q.AcceptedAnswerId, U.Reputation AS AnswererReputation, CAST((JULIANDAY(CreationDate) - JULIANDAY(Q.CreationDate)) * 1440.0 AS INT) AS QATimeGap FROM Posts AS Q, Posts AS A, Users AS U WHERE Q.AcceptedAnswerId = A.Id AND A.OwnerUserId = U.Id AND Q.Tags LIKE '%<android>%' AND Q.CreationDate > '2014-08-01'
### Instruction: What are the renting arrears tax ids related to the customer master index whose detail is not 'Schmidt, Kertzmann and Lubowitz'? ### Response:
SELECT T1.council_tax_id FROM rent_arrears AS T1 JOIN cmi_cross_references AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id JOIN customer_master_index AS T3 ON T3.master_customer_id = T2.master_customer_id WHERE T3.cmi_details <> 'Schmidt , Kertzmann and Lubowitz'
### Instruction: calculate how many times patient 7165 had the intake of sterile water po. ### 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 = 7165)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sterile water po' AND d_items.linksto = 'inputevents_cv')
### Instruction: in 08/this year when was patient 9299 prescribed for a medicine for the first time? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9299) AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '08' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: How many comments have you made on someone else specific's posts?. Other user defaults to Jon Skeet. ### Response:
SELECT p.OwnerUserId AS "user_link", c.PostId AS "post_link", p.Score, p.CreationDate AS "posted", c.CreationDate AS "commented", c.Score, c.Id AS "comment_link" FROM Comments AS c RIGHT OUTER JOIN Posts AS p ON c.PostId = p.Id WHERE c.UserId = '##UserID##' AND p.OwnerUserId = '##OtherUserID:int?22656##'
### Instruction: In the County of Prince, what was the highest Population density when the Area (km ) was larger than 3.02, and the Population (2006) was larger than 786, and the Population (2011) was smaller than 1135? ### Response:
SELECT MAX("Population density") FROM table_75771 WHERE "County" = 'prince' AND "Area (km\u00b2)" > '3.02' AND "Population (2006)" > '786' AND "Population (2011)" < '1135'
### Instruction: Percentage of users with 10,000 and 20,000 reputation or more. ### Response:
SELECT (((SELECT CAST(COUNT(*) AS FLOAT) FROM Users WHERE Reputation > 10000) / (SELECT CAST(COUNT(*) AS FLOAT) FROM Users)) * 100) AS PercentageOver10k, (((SELECT CAST(COUNT(*) AS FLOAT) FROM Users WHERE Reputation > 30000) / (SELECT CAST(COUNT(*) AS FLOAT) FROM Users)) * 100) AS PercentageOver20k
### Instruction: After GREEK 550 what courses can I take ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0 INNER JOIN course_prerequisite ON COURSE_0.course_id = course_prerequisite.course_id INNER JOIN course AS COURSE_1 ON COURSE_1.course_id = course_prerequisite.pre_course_id WHERE COURSE_1.department = 'GREEK' AND COURSE_1.number = 550
### Instruction: SnapComms Related Questions or Answers. ### Response:
SELECT CreationMonth, SUM(SnapCommsPosts) AS SnapCommsPosts FROM (SELECT CAST(YEAR(CreationDate) AS TEXT) + '-' + RIGHT('00' + CAST(MONTH(CreationDate) AS TEXT), 2) AS CreationMonth, CASE WHEN Body LIKE '%snapcomms%' THEN 1 ELSE 0 END AS SnapCommsPosts, Tags FROM Posts WHERE YEAR(CreationDate) >= 2015) AS C GROUP BY CreationMonth ORDER BY CreationMonth
### Instruction: self accepted answers in the given tag. ### Response:
SELECT selfAnswer.Id AS "post_link", question.Score AS QuestionScore, selfAnswer.Score AS AnswerScore, question.Tags FROM Posts AS question INNER JOIN Posts AS selfAnswer ON selfAnswer.OwnerUserId = question.OwnerUserId AND selfAnswer.ParentId = question.Id AND selfAnswer.Id = question.AcceptedAnswerId WHERE question.PostTypeId = 1 AND selfAnswer.PostTypeId = 2 AND question.Tags LIKE CONCAT('%', @TagName, '%') ORDER BY (question.Score + selfAnswer.Score) DESC, selfAnswer.CreationDate DESC
### Instruction: what is the average yearly number of patients with traumatic injury to major vessels - r femoral artery diagnosed since 2 years ago? ### Response:
SELECT AVG(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'traumatic injury to major vessels - r femoral artery' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY STRFTIME('%y', diagnosis.diagnosistime)) AS t1
### Instruction: How many courses for each course description? Show me a stacked bar chart The x-axis is course description and group by instructor's name, and sort names in descending order. ### Response:
SELECT CRS_DESCRIPTION, COUNT(CRS_DESCRIPTION) 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 GROUP BY EMP_FNAME, CRS_DESCRIPTION ORDER BY CRS_DESCRIPTION DESC
### Instruction: how many times on the current hospital encounter has patient 004-79017 received enteral perative? ### Response:
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-79017' AND patient.hospitaldischargetime IS NULL)) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'enteral perative'
### Instruction: what is the minimum cost in a hospital involving a laboratory test for lithium since 1 year ago? ### Response:
SELECT MIN(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 = 'lithium')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY cost.hadm_id) AS t1
### Instruction: is there any medication that has been prescribed to patient 016-6009 during the previous month? ### Response:
SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-6009')) AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
### Instruction: Bad question days by month. ### Response:
SELECT year_, month_, SUM(CASE WHEN down > 0 THEN 1 ELSE 0 END) AS bad_days FROM (SELECT YEAR(CreationDate) AS year_, MONTH(CreationDate) AS month_, MAX(CASE WHEN Score > 0 THEN 1 ELSE 0 END) AS up, MAX(CASE WHEN Score < 1 THEN 1 ELSE 0 END) AS down FROM Posts WHERE OwnerUserId = '##UserId##' AND PostTypeId = 1 GROUP BY CreationDate) AS question_days GROUP BY year_, month_ ORDER BY year_, month_
### Instruction: What computing infrastructure courses are offered in Spring or Summer 2012 ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE area.area LIKE '%computing infrastructure%' AND semester.semester IN ('SP', 'SU', 'SS') AND semester.year = 2012
### Instruction: Closed Status of All Questions by Reputation. A graph what percentage of questions are closed, grouped by the reputation of the users who asked them. ### Response:
SELECT AVG(ROUND(Reputation, -1)) AS UserReputation, SUM(CASE WHEN ClosedDate IS NULL THEN 1 ELSE 0 END) / CAST(COUNT(Posts.Id) AS FLOAT) AS "PercentOpen" FROM Posts INNER JOIN Users ON (Users.Id = Posts.OwnerUserId) WHERE PostTypeId = 1 AND Reputation < 1000 GROUP BY ROUND(Reputation, -1) ORDER BY UserReputation
### Instruction: show me all the US flights to PITTSBURGH between 1200 and 1600 in the afternoon ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service, city, flight WHERE ((flight.arrival_time <= 1600 AND flight.arrival_time >= 1200) AND city.city_code = airport_service.city_code AND city.city_name = 'PITTSBURGH' AND flight.to_airport = airport_service.airport_code) AND flight.airline_code = 'US'
### Instruction: what was the maximum value of patient 3929's mchc in this month? ### Response:
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3929) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'mchc') AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: what is in 02/2103 average ph value of patient 022-87224? ### 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 = '022-87224')) AND lab.labname = 'ph' AND STRFTIME('%y-%m', lab.labresulttime) = '2103-02'
### Instruction: what is patient 006-181433 first diagnosis time of polymyalgia rheumatica? ### Response:
SELECT diagnosis.diagnosistime FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-181433')) AND diagnosis.diagnosisname = 'polymyalgia rheumatica' ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: what was the time of patient 002-52932's first laboratory test when they visited the hospital first time? ### Response:
SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-52932' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) ORDER BY lab.labresulttime LIMIT 1
### Instruction: count the number of patients who had a carotid endarterectomy procedure performed two times until 1 year ago. ### 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 = 'carotid endarterectomy' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-1 year')) GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 = 2
### Instruction: what number of hours has it been since the last time patient 25733 was prescribed propofol on this hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25733 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'propofol' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: what were the four most frequently ordered laboratory tests until 2100 for patients aged 50s? ### 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 50 AND 59) AND STRFTIME('%y', lab.labresulttime) <= '2100' GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 4
### Instruction: until 2100, what are the four commonly given lab tests for patients with 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 STRFTIME('%y', lab.labresulttime) <= '2100' GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 4
### Instruction: how many days have passed since the first time dexamethasone was prescribed patient 1902 in their current hospital encounter? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1902 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'dexamethasone' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: what are the top five most frequent procedures in patients of age 60 or above in 2103? ### 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 >= 60) AND STRFTIME('%y', treatment.treatmenttime) = '2103' GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 5
### Instruction: who are all the co-authors of Srinivasan Iyer ? ### Response:
SELECT DISTINCT AUTHOR_1.authorid FROM author AS AUTHOR_0, author AS AUTHOR_1, writes AS WRITES_0, writes AS WRITES_1 WHERE AUTHOR_0.authorname = 'Srinivasan Iyer' AND WRITES_0.authorid = AUTHOR_0.authorid AND WRITES_1.authorid = AUTHOR_1.authorid AND WRITES_1.paperid = WRITES_0.paperid
### Instruction: what is the daily minimum bicarbonate value for patient 10624 on this hospital encounter? ### Response:
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10624 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'bicarbonate') GROUP BY STRFTIME('%y-%m-%d', labevents.charttime)
### Instruction: Which MODGREEK classes are considered upper-level this Spring ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND course.department = 'MODGREEK' 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 = 2016
### Instruction: Find the transaction type descriptions and dates if the share count is smaller than 10, group by transaction type, count the date of transaction, and bin the date into the weekday interval Show the result with a grouping line chart, and order by the x axis in descending. ### Response:
SELECT T2.date_of_transaction, COUNT(T2.date_of_transaction) FROM Ref_Transaction_Types AS T1 JOIN Transactions AS T2 ON T1.transaction_type_code = T2.transaction_type_code WHERE T2.share_count < 10 GROUP BY transaction_type_description ORDER BY date_of_transaction DESC
### Instruction: count the number of patients who have already received the blood product administration - packed red blood cells two times since 2105. ### 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 = 'blood product administration - packed red blood cells' AND STRFTIME('%y', treatment.treatmenttime) >= '2105') GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 = 2
### Instruction: How many courses for each course description? Show me a bar chart, list by the X in desc. ### Response:
SELECT CRS_DESCRIPTION, COUNT(CRS_DESCRIPTION) 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 ORDER BY CRS_DESCRIPTION DESC