instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: tell me what the top four most common output events during the previous year were. ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT outputevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM outputevents WHERE DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY outputevents.itemid) AS t1 WHERE t1.c1 <= 4)
### Instruction: Is there an CHEM 398 section that is not on Monday next semester ? ### Response:
SELECT DISTINCT course_offering.section_number FROM course, course_offering, semester WHERE course_offering.monday = 'N' AND course.course_id = course_offering.course_id AND course.department = 'CHEM' AND course.number = 398 AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: is there a microbiology test result in this month for patient 13054's sputum? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13054) AND microbiologyevents.spec_type_desc = 'sputum' AND DATETIME(microbiologyevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: calculate how many drugs patient 015-94586 is prescribed in 06/2101. ### Response:
SELECT COUNT(*) FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-94586')) AND STRFTIME('%y-%m', medication.drugstarttime) = '2101-06'
### Instruction: did patient 030-6441 have a wound care procedure at other hospitals? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '030-6441' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '030-6441' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'wound care'
### Instruction: give me the number of patients whose primary disease is coronary artery disease\coronary artery bypass graft; myomectomy/sda and lab test fluid is pleural? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT; MYOMECTOMY/SDA" AND lab.fluid = "Pleural"
### Instruction: Information on tags (included deleted ones). ### Response:
SELECT e.Body, w.Body, e.Id, e.CreationDate, e.LastEditorUserId AS "user_link", e.LastEditDate, w.Id, w.CreationDate, w.LastEditorUserId AS "user_link", w.LastEditDate FROM Tags AS t LEFT OUTER JOIN Posts AS e ON t.ExcerptPostId = e.Id LEFT OUTER JOIN Posts AS w ON t.WikiPostId = w.Id WHERE t.TagName = '##tagname:string##'
### Instruction: tell me the diagnosis cost of duodenitis w hmrhg in a patient? ### Response:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'diagnoses_icd' AND cost.event_id IN (SELECT diagnoses_icd.row_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 = 'duodenitis w hmrhg'))
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, a bar chart shows the distribution of hire_date and the sum of department_id bin hire_date by weekday, and show y axis in ascending order. ### Response:
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SUM(DEPARTMENT_ID)
### Instruction: have there been any microbiological catheter tip-iv tests for patient 76332 in 12/2105? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 76332) AND microbiologyevents.spec_type_desc = 'catheter tip-iv' AND STRFTIME('%y-%m', microbiologyevents.charttime) = '2105-12'
### Instruction: Give me the number of patients diagnosed with type 1 diabetes with renal manifestations that were not stated as uncontrolled who had vasopressor infusion. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE diagnoses.short_title = "DMI renl nt st uncntrld" AND procedures.short_title = "Infusion of vasopressor"
### Instruction: what test did patient 3403 go through for the first time since 04/2105? ### 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 = 3403) AND STRFTIME('%y-%m', labevents.charttime) >= '2105-04' ORDER BY labevents.charttime LIMIT 1)
### Instruction: calculate the number of patients who had had a cd3 cells, percent lab test in this year. ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'cd3 cells, percent') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
### Instruction: when did patient 9294 receive a prescription for nadolol in this month first? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9294) AND prescriptions.drug = 'nadolol' AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY prescriptions.startdate LIMIT 1
### Instruction: what are commonly cited papers by tom mitchell and oren etzioni ? ### Response:
SELECT DISTINCT author.authorname, cite.citedpaperid, COUNT(cite.citedpaperid) FROM author, cite, paper, writes WHERE author.authorname IN ('tom mitchell', 'oren etzioni') AND paper.paperid = cite.citedpaperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid GROUP BY cite.citedpaperid, author.authorname ORDER BY COUNT(cite.citedpaperid) DESC
### Instruction: uses of the word 'qua'. ### Response:
SELECT UserId, Text, Id, 'comment' FROM Comments WHERE Text LIKE @match UNION SELECT UserId, Text, Id, 'posthistory text' FROM PostHistory WHERE Text LIKE @match UNION SELECT UserId, Comment, Id, 'posthistory comment' FROM PostHistory WHERE Comment LIKE @match UNION SELECT OwnerUserId, Text, Id, 'suggestededit text' FROM SuggestedEdits WHERE Text LIKE @match UNION SELECT OwnerUserId, Title, Id, 'suggestededit title' FROM SuggestedEdits WHERE Title LIKE @match
### Instruction: count the number of patients whose diagnoses long title is venous (peripheral) insufficiency, unspecified and drug route is iv? ### 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 = "Venous (peripheral) insufficiency, unspecified" AND prescriptions.route = "IV"
### Instruction: count the number of patients whose diagnoses long title is fall from other slipping, tripping, or stumbling and drug type is additive? ### 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 = "Fall from other slipping, tripping, or stumbling" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: Questions with more than n answers. ### Response:
SELECT q.Id, q.Title, q.Body, q.AnswerCount, a.Id, a.Body, q.CreationDate, a.CreationDate, q.ClosedDate, a.ClosedDate, q.ViewCount, q.OwnerUserId, a.OwnerUserId, q.FavoriteCount FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id WHERE q.PostTypeId = 1 AND a.PostTypeId = 2 AND q.AnswerCount >= 10
### Instruction: How to list posts which have a particular tag but didn't have it when originally asked?. https://meta.stackexchange.com/questions/355412 ### Response:
SELECT DISTINCT PostId AS "post_link" FROM PostHistory AS ph WHERE PostHistoryTypeId = 6 AND Text LIKE CONCAT('%<', '##tagname:string##', '>%') AND NOT EXISTS(SELECT PostId FROM PostHistory WHERE PostHistoryTypeId = 3 AND PostId = ph.PostId AND Text LIKE CONCAT('%<', '##tagname:string##', '>%'))
### Instruction: Find the name and address of the customers who have both New and Pending orders. ### Response:
SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "New" INTERSECT SELECT T1.customer_name, T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "Pending"
### Instruction: A bar chart for what are the number of the dates of birth of entrepreneurs with investor 'Simon Woodroffe' or 'Peter Jones'?, and I want to rank total number in ascending order. ### Response:
SELECT Date_of_Birth, COUNT(Date_of_Birth) FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Investor = "Simon Woodroffe" OR T1.Investor = "Peter Jones" ORDER BY COUNT(Date_of_Birth)
### Instruction: What is the sum of number of bearers in 2009 for a rank above 1, a type of patronymic, an etymology meaning son of Christian, and the number of bearers in 1971 greater than 45.984? ### Response:
SELECT SUM(number_of_bearers_2009) FROM table_name_3 WHERE rank > 1 AND type = "patronymic" AND etymology = "son of christian" AND number_of_bearers_1971 > 45.984
### Instruction: when did patient 002-76184 for the first time have an intake? ### Response:
SELECT intakeoutput.intakeoutputtime FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-76184')) AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: how many times during their current hospital visit is patient 022-187132 getting a vitamin b12 test? ### 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 = '022-187132' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'vitamin b12'
### Instruction: what intake did patient 14203 have for the last time? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT inputevents_cv.itemid FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14203)) ORDER BY inputevents_cv.charttime DESC LIMIT 1)
### Instruction: until 28 months ago, what was the first drug patient 27172 was prescribed via the iv drip route? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27172) AND prescriptions.route = 'iv drip' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-28 month') ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Can you tell me who the teacher is for ANTHRBIO 161 ? ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'ANTHRBIO' AND course.number = 161 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: until 3 years ago, what were the top five most common intakes? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT inputevents_cv.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM inputevents_cv WHERE DATETIME(inputevents_cv.charttime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY inputevents_cv.itemid) AS t1 WHERE t1.c1 <= 5)
### Instruction: Among patients who had a lab test for urine, how many of them had coronary artery disease or coronary artery bypass graft with MVR maze as their primary disease? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT WITH MVR; ? MAZE" AND lab.fluid = "Urine"
### Instruction: What is the resurrection of 144,000 date with a Christ made king date in 1914, a separting sheep & goats date during Christ's presence, and a judgment of religion date in 1878? ### Response:
SELECT "Resurrection of144,000" FROM table_7479 WHERE "Christ madeKing" = '1914' AND "Separating Sheep &Goats" = 'during christ''s presence' AND "Judgmentof Religion" = '1878'
### Instruction: Average Question Score by Hour. Find out if time of day when you ask a question may affect the number of votes you receive. Results are skewed by different parts of the world being awake at different times, with each region possibly asking questions of different perceived quality. ### Response:
SELECT TIME_TO_STR(CreationDate, '%h') AS hour, COUNT(*) AS posts, AVG(CAST(Score AS FLOAT)) AS "average score" FROM Posts GROUP BY TIME_TO_STR(CreationDate, '%h') ORDER BY hour
### Instruction: how many patients have been diagnosed with unspecified fetal and neonatal jaundice and were given the drug tamsulosin? ### 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 = "Unspecified fetal and neonatal jaundice" AND prescriptions.drug = "Tamsulosin"
### Instruction: calculate the number of times that patient 006-195310 had hemovac total discharge. ### 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 = '006-195310')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'hemovac total'
### Instruction: which opponents in the u.s. championships played after 1945 and had a score of 3 6, 6 4, 2 6, 6 3, 20 18? ### Response:
SELECT "Opponents in the final" FROM table_77473 WHERE "Championship" = 'u.s. championships' AND "Year" > '1945' AND "Score" = '3–6, 6–4, 2–6, 6–3, 20–18'
### Instruction: Next semester , what upper level CS classes will there be ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN program_course ON program_course.course_id = course.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 program_course.category LIKE '%ULCS%' AND semester.semester = 'FA' AND semester.year = 2016
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, a bar chart shows the distribution of hire_date and the sum of salary bin hire_date by weekday, rank from high to low by the y axis. ### Response:
SELECT HIRE_DATE, SUM(SALARY) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SUM(SALARY) DESC
### Instruction: Course 322 has been taught by Prof. Zuzana Srostlik how many times ? ### Response:
SELECT COUNT(*) FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.number = 322 AND instructor.name LIKE '%Zuzana Srostlik%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: question score vs top answer score. ### Response:
SELECT rbin, COUNT(*) FROM (SELECT ROUND(CAST(q.Score AS FLOAT) / a.maxScore, 1) AS rbin FROM (SELECT ParentId, MAX(Score) AS maxScore FROM Posts WHERE PostTypeId = 2 GROUP BY ParentId) AS a JOIN Posts AS q ON q.Id = a.ParentId WHERE a.maxScore >= '##minTopAnswerScore?5##' AND q.Score >= '##minQuestionScore?0##') AS r GROUP BY rbin ORDER BY rbin
### Instruction: What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers? ### Response:
SELECT T1.staff_name, T1.staff_id FROM Staff AS T1 JOIN Fault_Log AS T2 ON T1.staff_id = T2.recorded_by_staff_id EXCEPT SELECT T3.staff_name, T3.staff_id FROM Staff AS T3 JOIN Engineer_Visits AS T4 ON T3.staff_id = T4.contact_staff_id
### Instruction: give me the number of patients whose diagnoses short title is atrial fibrillation and procedure long title is other and unspecified coronary arteriography? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE diagnoses.short_title = "Atrial fibrillation" AND procedures.long_title = "Other and unspecified coronary arteriography"
### Instruction: count the number of patients who were tested since 1 year ago for bilirubin, total, body fluid. ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'bilirubin, total, body fluid') AND DATETIME(labevents.charttime) >= DATETIME(CURRENT_TIME(), '-1 year'))
### Instruction: did patient 003-39724 suffer from any type of allergy until 1 year ago? ### Response:
SELECT COUNT(*) > 0 FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-39724')) AND DATETIME(allergy.allergytime) <= DATETIME(CURRENT_TIME(), '-1 year')
### Instruction: How old are the students with allergies to food and animal types on average? ### Response:
SELECT AVG(age) FROM student WHERE stuid IN (SELECT T1.stuid FROM has_allergy AS T1 JOIN allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = "food" INTERSECT SELECT T1.stuid FROM has_allergy AS T1 JOIN allergy_type AS T2 ON T1.allergy = T2.allergy WHERE T2.allergytype = "animal")
### Instruction: give me the top three most common diagnoses? ### Response:
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
### Instruction: What rank has an annual interchange less than 1.99 million, an annual entry/exit less than 13.835 million, and more than 13.772 million total passengers? ### Response:
SELECT rank FROM table_name_83 WHERE annual_interchanges__millions__2011_12 < 1.99 AND annual_entry_exit__millions__2011_12 < 13.835 AND total_passengers__millions__2011_12 > 13.772
### Instruction: Which classes are offered next Winter for Core ? ### 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_offering.course_id WHERE program_course.category LIKE '%Core%' AND semester.semester = 'Winter' AND semester.year = 2017
### Instruction: did patient 031-3355 have any kind of microbiology test in the first hospital visit? ### Response:
SELECT COUNT(*) > 0 FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-3355' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1))
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of salary over the job_id , and group by attribute job_id. ### 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
### Instruction: Am I close to the 'Self-Learner'-badge?. This returns all your questions, where you have added a self-answer with a score of 2 or higher. ### Response:
SELECT a.ParentId AS "Question Id", a.Score AS "Answer Score", b.Title AS "Question Title" FROM Posts AS a INNER JOIN Posts AS b ON b.Id = a.ParentId WHERE a.OwnerUserId = '##UserId##' AND a.PostTypeId = 2 AND b.OwnerUserId = a.OwnerUserId AND a.Score > 2
### Instruction: What is Cabinet, when Year is before 2001, when Lijsttrekker is 'No Elections', when Fractievoorzitter is 'Hans Van Mierlo', and when Chair is 'S. Van Der Loo'? ### Response:
SELECT "Cabinet" FROM table_9585 WHERE "Year" < '2001' AND "Lijsttrekker" = 'no elections' AND "Fractievoorzitter" = 'hans van mierlo' AND "Chair" = 's. van der loo'
### Instruction: Can you list the JUDAIC classes that don 't meet on Friday ? ### 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 WHERE course_offering.friday = 'N' AND course.department = 'JUDAIC' AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: provide the number of patients diagnosed with other and unspecified hyperlipidemia who had central venous catheter placement with guidance. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE diagnoses.long_title = "Other and unspecified hyperlipidemia" AND procedures.long_title = "Central venous catheter placement with guidance"
### Instruction: Most viewed questions with a tag converted to a synonym since then. ### Response:
SELECT Posts.Id AS "post_link", Posts.ViewCount, TagSynonyms.SourceTagName AS "Its tag...", TagSynonyms.TargetTagName AS "...is a synonym of" FROM TagSynonyms, Tags, PostTags, Posts WHERE Tags.TagName = TagSynonyms.SourceTagName AND PostTags.TagId = Tags.Id AND Posts.Id = PostTags.PostId ORDER BY Posts.ViewCount DESC, Posts.Id DESC LIMIT 100
### Instruction: until 31 months ago, what was the first drug patient 1704 was prescribed via the po/ng route? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1704) AND prescriptions.route = 'po/ng' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-31 month') ORDER BY prescriptions.startdate LIMIT 1
### Instruction: what is the number of times patient 28966 has received a glucose lab test until 2103? ### Response:
SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'glucose') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 28966) AND STRFTIME('%y', labevents.charttime) <= '2103'
### Instruction: what was the name of the drug that patient 92788 had been prescribed two times in this hospital encounter. ### 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 = 92788 AND admissions.dischtime IS NULL) GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
### Instruction: until 09/2105 has patient 5395 received a rdw test? ### Response:
SELECT COUNT(*) > 0 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'rdw') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 5395) AND STRFTIME('%y-%m', labevents.charttime) <= '2105-09'
### Instruction: tell me the length of stay of patient 006-83902's last stay in the icu. ### Response:
SELECT STRFTIME('%j', patient.unitdischargetime) - STRFTIME('%j', patient.unitadmittime) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-83902') AND NOT patient.unitadmittime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: what is the built when s.r. number is less than 2033, lb&sc number is less than 18, notes is i2 and withdrawal is cannot handle non-empty timestamp argument! 1935? ### Response:
SELECT "Built" FROM table_8295 WHERE "S.R. Number" < '2033' AND "LB&SC Number" < '18' AND "Notes" = 'i2' AND "Withdrawal" = 'cannot handle non-empty timestamp argument! 1935'
### Instruction: Tag Usage - Storage Frameworks. ### Response:
SELECT t.TagName, COUNT(p.Id) AS Posts, SUM(CASE WHEN p.AnswerCount > 0 THEN 1 ELSE 0 END) AS Answered FROM Tags AS t INNER JOIN PostTags AS pta ON t.Id = pta.TagId INNER JOIN Posts AS p ON p.Id = pta.PostId AND p.PostTypeId = 1 WHERE t.TagName IN ('hibernate', 'eclipselink', 'spring-data', 'jooq', 'jpa') GROUP BY t.TagName
### Instruction: how many patients are diagnosed with primary disease coronary artery disease or coronary artery bypass graft myomectomy/sda and tested with blood in lab? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT; MYOMECTOMY/SDA" AND lab.fluid = "Blood"
### Instruction: what are the four most common specimen test performed in this year? ### Response:
SELECT t1.spec_type_desc FROM (SELECT microbiologyevents.spec_type_desc, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microbiologyevents WHERE DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 4
### Instruction: there is a microbiology test record for patient 3663's mrsa screen until 09/2105? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3663) AND microbiologyevents.spec_type_desc = 'mrsa screen' AND STRFTIME('%y-%m', microbiologyevents.charttime) <= '2105-09'
### Instruction: what does it cost to get open wound of neck nec diagnosed? ### Response:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'diagnoses_icd' AND cost.event_id IN (SELECT diagnoses_icd.row_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 = 'open wound of neck nec'))
### Instruction: Report the number of patients on additive type drug prescriptions who have the diagnoses of chronic combined systolic and diastolic heart failure. ### 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.short_title = "Chr syst/diastl hrt fail" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: Sandbox: # of Posts by Users Inactive for X Months. ### Response:
SELECT 'https://codegolf.meta.stackexchange.com/a/' + CAST(P.Id AS VARCHAR) + '/43214|' + CAST(P.Score AS VARCHAR) FROM Posts AS P WHERE (LastActivityDate < DATEADD(mm, -'##Month##', GETDATE()) AND EXISTS(SELECT * FROM Users AS U WHERE LastAccessDate < DATEADD(mm, -'##Month##', GETDATE()) AND U.Id = P.OwnerUserId))
### Instruction: what the last height of patient 008-24610 in 05/2105. ### Response:
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '008-24610') AND NOT patient.admissionheight IS NULL AND STRFTIME('%y-%m', patient.unitadmittime) = '2105-05' ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: did patient 016-23497 have any medication until 2 years ago? ### Response:
SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-23497')) AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-2 year')
### Instruction: Most downvoted questions or answers.. Most downvoted questions or answers. PostTypeId for questions is 1, answers 2. Feel free to improve the query. ### Response:
SELECT Posts.CreationDate AS "creation_date", Posts.OwnerUserId AS "user_link", Posts.Id AS "post/answer_link", Posts.Score AS "score" FROM Posts WHERE PostTypeId = 1 AND CommunityOwnedDate IS NULL GROUP BY CreationDate, OwnerUserId, Id, Score ORDER BY 'score' LIMIT 50
### 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 hire_date and the sum of manager_id bin hire_date by weekday. ### Response:
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: Collect aggregate results for users. ### Response:
SELECT u.Id, u.Reputation, (SELECT COUNT(*) FROM Votes WHERE VoteTypeId IN (2, 3) AND PostId IN (SELECT Id FROM Posts WHERE PostTypeId = 1 AND OwnerUserId = u.Id)) AS "aggregate_number_of_votes_received_on_questions" FROM Users AS u WHERE u.Id IN (83, 2926, 3289, 5862, 6292, 8705)
### Instruction: Average total score of users depending on number of posts. ### Response:
WITH postgroups_cte AS (SELECT u.Id AS uid, SUM(p.Score) AS sco, CAST(COUNT(p.Id) / '##mult?100##' AS INT) AS pgroup FROM Users AS u INNER JOIN Posts AS p ON p.OwnerUserId = u.Id GROUP BY u.Id) SELECT pgroup, AVG(CAST(sco AS FLOAT)) AS Average FROM postgroups_cte GROUP BY pgroup ORDER BY pgroup DESC
### Instruction: tell me what is the top five most common specimen tests in the previous year? ### Response:
SELECT t1.culturesite FROM (SELECT microlab.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microlab WHERE DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY microlab.culturesite) AS t1 WHERE t1.c1 <= 5
### Instruction: when was the first time patient 72107 had dextrose 50% prescribed on their first hospital visit? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 72107 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND prescriptions.drug = 'dextrose 50%' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Who has taught , is teaching , or will teach RCCORE 104 ? ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'RCCORE' AND course.number = 104 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: provide the number of patients whose diagnoses short title is dementia w/o behav dist and lab test fluid is cerebrospinal fluid (csf)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.short_title = "Dementia w/o behav dist" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: had patient 006-80884 ever been diagnosed with anything in their first hospital visit? ### 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 = '006-80884' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1))
### Instruction: how much does the cost of a candidiasis of lung diagnosis cost? ### Response:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'diagnoses_icd' AND cost.event_id IN (SELECT diagnoses_icd.row_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 = 'candidiasis of lung'))
### Instruction: when did patient 006-127563 last get the respiratory rate test in the laboratory? ### Response:
SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-127563')) AND lab.labname = 'respiratory rate' ORDER BY lab.labresulttime DESC LIMIT 1
### Instruction: count the number of patients whose drug code is eryt250 and lab test fluid is cerebrospinal fluid (csf)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE prescriptions.formulary_drug_cd = "ERYT250" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: all adult patients with severe sepsis or septic shock, who have arterial catheter placed with flotrac monitor, with or without a central venous catheter. ### Response:
SELECT * FROM table_train_10 WHERE age >= 18 AND (severe_sepsis = 1 OR septic_shock = 1) AND intention_to_arterial_catheter = 1 AND (intention_to_central_venous_catheter = 0 OR intention_to_central_venous_catheter = 1)
### Instruction: Find the titles of papers whose first author is affiliated with an institution in the country 'Japan' and has last name 'Ohori'? ### Response:
SELECT t3.title FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid JOIN inst AS t4 ON t2.instid = t4.instid WHERE t4.country = "Japan" AND t2.authorder = 1 AND t1.lname = "Ohori"
### Instruction: how many hours have passed since patient 032-21820 stayed in the ward 1063 for the last time in their current hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '032-21820' AND patient.wardid = 1063 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: Are there set exams for Prof. James Pinto 's classes ? ### 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.has_exams = 'N' AND instructor.name LIKE '%James Pinto%'
### Instruction: the previous year, what were the five most common input events? ### Response:
SELECT t1.celllabel FROM (SELECT intakeoutput.celllabel, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM intakeoutput WHERE intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 5
### Instruction: Return the dates of birth for entrepreneurs who have either the investor Simon Woodroffe or Peter Jones, and count them by a line chart, sort by the Date_of_Birth in desc. ### Response:
SELECT Date_of_Birth, COUNT(Date_of_Birth) FROM entrepreneur AS T1 JOIN people AS T2 ON T1.People_ID = T2.People_ID WHERE T1.Investor = "Simon Woodroffe" OR T1.Investor = "Peter Jones" ORDER BY Date_of_Birth DESC
### Instruction: cardiogenic shock ( hypotension with systolic blood pressure ( sbp ) < 90 mmhg and tachycardia > 100 beats / min, not due to hypovolemia and requiring inotropic support or balloon counterpulsation ) ; ### Response:
SELECT * FROM table_test_21 WHERE cardiogenic_shock = 1 OR (hypotension = 1 AND systolic_blood_pressure_sbp < 90 AND tachycardia > 100)
### Instruction: tell me the price of a procedure called endoscop dilate pylorus? ### Response:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'procedures_icd' AND cost.event_id IN (SELECT procedures_icd.row_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 = 'endoscop dilate pylorus'))
### Instruction: what did patient 17286 receive for his or her first procedure? ### 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 = 17286) ORDER BY procedures_icd.charttime LIMIT 1)
### Instruction: this year, what were the five most common input events? ### Response:
SELECT t1.celllabel FROM (SELECT intakeoutput.celllabel, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM intakeoutput WHERE intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 5
### Instruction: tell me the top three most common intake last year? ### Response:
SELECT t1.celllabel FROM (SELECT intakeoutput.celllabel, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM intakeoutput WHERE intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 3
### Instruction: How many upvotes do I have for each tag (by User Name)?. how long before I get tag badges? ### Response:
SELECT TagName, COUNT(*) AS UpVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Users ON Posts.OwnerUserId = Users.Id INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2 WHERE Users.DisplayName = @UserName GROUP BY TagName ORDER BY UpVotes DESC
### Instruction: Users who posted the most recent comments. ### Response:
WITH recent_cte AS (SELECT UserId AS uid, MAX(Id) AS MaxId FROM Comments WHERE (CreationDate >= '##datemin?2018-01-01##') GROUP BY UserId) SELECT uid AS "user_link", c.CreationDate, MaxId AS "comment_link", c.PostId AS "post_link", c.Text FROM recent_cte INNER JOIN Comments AS c ON MaxId = c.Id ORDER BY c.CreationDate DESC
### Instruction: what's the five most frequent input event since 2105? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT inputevents_cv.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM inputevents_cv WHERE STRFTIME('%y', inputevents_cv.charttime) >= '2105' GROUP BY inputevents_cv.itemid) AS t1 WHERE t1.c1 <= 5)
### Instruction: provide the number of patients whose diagnoses long title is infection with microorganisms resistant to penicillins and lab test category is chemistry? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Infection with microorganisms resistant to penicillins" AND lab."CATEGORY" = "Chemistry"
### Instruction: give the number of patients whose diagnoses long title is personal history of malignant neoplasm of bladder and lab test abnormal status is abnormal. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Personal history of malignant neoplasm of bladder" AND lab.flag = "abnormal"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, return a bar chart about the distribution of first_name and commission_pct , I want to show by the Y-axis from high to low. ### Response:
SELECT FIRST_NAME, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY COMMISSION_PCT DESC
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, draw a bar chart about the distribution of hire_date and the average of salary bin hire_date by time. ### Response:
SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: Possible Silencium candidates, with comments on the Q after posting the A. ### Response:
SELECT a.Id AS "post_link" FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id LEFT OUTER JOIN Comments AS c ON c.PostId = q.Id AND c.CreationDate < a.CreationDate WHERE a.Score >= 7 AND a.CommentCount = 0 AND q.CommentCount > 0 AND a.CreationDate >= '2017-12-13' AND c.Id IS NULL