instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: what was the first amount of abciximab that was prescribed to patient 11322 during the first hospital encounter? ### Response:
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 11322 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND prescriptions.drug = 'abciximab' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: tell me the name of the organism that was detected in the first catheter tip-iv test of patient 74392? ### Response:
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 74392) AND microbiologyevents.spec_type_desc = 'catheter tip-iv' AND NOT microbiologyevents.org_name IS NULL ORDER BY microbiologyevents.charttime LIMIT 1
### Instruction: Hot Meta Post vs Comment Count. ### Response:
SELECT TIME_TO_STR(CreationDate, '%W') AS "week", COUNT(*) AS "comment_count", CASE WHEN TIME_TO_STR(CreationDate, '%W') > 30 THEN 0 ELSE 1000 END AS "hot_meta_posts_enabled" FROM Comments WHERE CreationDate > '2019-04-01' GROUP BY TIME_TO_STR(CreationDate, '%W') ORDER BY TIME_TO_STR(CreationDate, '%W')
### Instruction: how much is a diagnosis of fx astragalus-closed going to 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 = 'fx astragalus-closed'))
### Instruction: what is the price of diagnosis of uterine leiomyoma nos? ### 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 = 'uterine leiomyoma nos'))
### Instruction: Users who favorited posts answered by an user. ### Response:
SELECT P.Id AS "post_link", UV.Id AS "user_link" FROM Votes AS V INNER JOIN Posts AS P ON P.ParentId = V.PostId INNER JOIN Users AS UV ON UV.Id = V.UserId INNER JOIN Users AS UA ON UA.Id = P.OwnerUserId WHERE UA.Id = '##UserId##' AND P.PostTypeId = 2 AND V.VoteTypeId = 5 ORDER BY P.Id, UV.DisplayName
### Instruction: Questions in a tag that haven't had activity. ### Response:
SELECT Posts.Id AS "post_link", Posts.LastActivityDate FROM ((Posts JOIN PostTypes ON Posts.PostTypeId = PostTypes.Id) JOIN (PostTags JOIN Tags ON PostTags.TagId = Tags.Id) ON Posts.Id = PostTags.PostId) WHERE Tags.TagName = @tagName AND DATEADD(m, @ageInMonths, Posts.LastActivityDate) < GETDATE() AND PostTypes.Name = 'Question' ORDER BY Posts.LastActivityDate
### Instruction: count the number of patients whose diagnoses long title is chronic total occlusion of coronary artery and drug name is ondansetron? ### 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 = "Chronic total occlusion of coronary artery" AND prescriptions.drug = "Ondansetron"
### Instruction: How many students taking a course who received an A or C? Group by students' first name with a bar chart, and display in desc by the total number. ### Response:
SELECT STU_FNAME, COUNT(STU_FNAME) FROM STUDENT AS T1 JOIN ENROLL AS T2 ON T1.STU_NUM = T2.STU_NUM WHERE T2.ENROLL_GRADE = 'C' OR T2.ENROLL_GRADE = 'A' GROUP BY STU_FNAME ORDER BY COUNT(STU_FNAME) DESC
### Instruction: what was the name of procedure, that patient 015-58787 was last received on their current hospital encounter? ### 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 = '015-58787' 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, return a bar chart about the distribution of hire_date and the amount of hire_date bin hire_date by weekday. ### Response:
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: how much does it cost for a diagnosis of mixed acid-base bal dis? ### 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 = 'mixed acid-base bal dis'))
### 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: tell me the name of the specimen test that patient 6170 first received during this month? ### Response:
SELECT microbiologyevents.spec_type_desc FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6170) AND DATETIME(microbiologyevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY microbiologyevents.charttime LIMIT 1
### 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: count the number of patients who have received the bicarbonate, stool test since 4 years ago. ### 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 = 'bicarbonate, stool') AND DATETIME(labevents.charttime) >= DATETIME(CURRENT_TIME(), '-4 year'))
### Instruction: whats the first height of patient 002-59265 until 02/2101? ### Response:
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-59265') AND NOT patient.admissionheight IS NULL AND STRFTIME('%y-%m', patient.unitadmittime) <= '2101-02' ORDER BY patient.unitadmittime LIMIT 1
### Instruction: what's the last weight of patient 006-7325 until 05/2104? ### Response:
SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-7325') AND NOT patient.admissionweight IS NULL AND STRFTIME('%y-%m', patient.unitadmittime) <= '2104-05' ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: how many patients whose diagnoses long title is diaphragmatic hernia without mention of obstruction or gangrene and lab test fluid is urine? ### 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 = "Diaphragmatic hernia without mention of obstruction or gangrene" AND lab.fluid = "Urine"
### Instruction: calculate the number of times until 3 years ago patient 19691 has received a mcv lab test. ### Response:
SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'mcv') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19691) AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-3 year')
### Instruction: How many papers related to deep learning cited the dataset ImageNet ? ### Response:
SELECT DISTINCT COUNT(paper.paperid) FROM dataset, keyphrase, paper, paperdataset, paperkeyphrase WHERE dataset.datasetname = 'ImageNet' AND keyphrase.keyphrasename = 'deep learning' AND paperdataset.datasetid = dataset.datasetid AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperdataset.paperid AND paper.paperid = paperkeyphrase.paperid
### Instruction: how many patients have received a minoxidil in 2105 two or more times? ### Response:
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, COUNT(*) AS c1 FROM patient WHERE patient.patientunitstayid = (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'minoxidil' AND STRFTIME('%y', treatment.treatmenttime) = '2105') GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 >= 2
### Instruction: how many patients whose diagnoses long title is other stomatitis and mucositis (ulcerative) and lab test category is blood gas? ### 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 = "Other stomatitis and mucositis (ulcerative)" AND lab."CATEGORY" = "Blood Gas"
### Instruction: what was the total hemorrhoidal suppository dose that was prescribed on the last hospital encounter to patient 50480? ### Response:
SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 50480 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND prescriptions.drug = 'hemorrhoidal suppository'
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of department_id over the hire_date bin hire_date by weekday. ### Response:
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: What is the total number of First Year, when Displacement CC is greater than 4719, when Engine is V8, when Power HP (kW) is '335 (246)', and when Model is 'Ghibli SS'? ### Response:
SELECT COUNT("First Year") FROM table_78713 WHERE "Displacement cc" > '4719' AND "Engine" = 'v8' AND "Power hp (kW)" = '335 (246)' AND "Model" = 'ghibli ss'
### Instruction: What was the 2012/13 result for the tournament that had a 2006/07 and 2007/08 finish of LQ, with the tournament not held in 2009/10? ### Response:
SELECT "2012/ 13" FROM table_46979 WHERE "2007/ 08" = 'lq' AND "2006/ 07" = 'lq' AND "2009/ 10" = 'tournament not held'
### Instruction: was there any results of microbiology tests for the stool (received in transport system) of patient 6196 during the last hospital visit? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6196 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND microbiologyevents.spec_type_desc = 'stool (received in transport system)'
### Instruction: Questions Per Day Over Specific Time Period. ### Response:
SELECT COUNT(Id) AS NumPosts, DATEDIFF(dd, MIN(CreationDate), MAX(CreationDate)) AS NumDays, ROUND(CAST(COUNT(Id) AS FLOAT) / CAST(DATEDIFF(dd, (GETDATE() - '##DaysAgo:int?365##'), GETDATE()) AS FLOAT), 2) AS QPD FROM Posts WHERE PostTypeId = 1 AND CreationDate >= GETDATE() - '##DaysAgo##'
### Instruction: what is patient 015-67291's length of stay in the icu for the last time? ### Response:
SELECT STRFTIME('%j', patient.unitdischargetime) - STRFTIME('%j', patient.unitadmittime) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-67291') AND NOT patient.unitadmittime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: show me the length of time patient 027-68991 was in the icu for the last time. ### Response:
SELECT STRFTIME('%j', patient.unitdischargetime) - STRFTIME('%j', patient.unitadmittime) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-68991') AND NOT patient.unitadmittime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: during the last hospital encounter, had patient 006-40255 had any allergies? ### 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 = '006-40255' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1))
### Instruction: what are the three intakes that are the most frequent until 2101? ### 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) <= '2101' GROUP BY inputevents_cv.itemid) AS t1 WHERE t1.c1 <= 3)
### Instruction: what are some syntactic parsing papers that chris dyer did not write ? ### Response:
SELECT DISTINCT author.authorname, paper.paperid FROM author, keyphrase, paper, paperkeyphrase, writes WHERE author.authorname <> 'chris dyer' AND keyphrase.keyphrasename = 'syntactic parsing' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
### Instruction: how much does it cost for a procedure called lap creat esoph sphinct? ### 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 = 'lap creat esoph sphinct'))
### Instruction: Rank users by what fraction of their answers are accepted. ### Response:
SELECT Users.Id AS "user_link", COUNT(*) AS "Answers", CAST(COUNT(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 END) AS FLOAT) / COUNT(*) AS "Fraction" FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id INNER JOIN Users ON a.OwnerUserId = Users.Id GROUP BY Users.Id HAVING COUNT(*) >= @MinAnswers ORDER BY 'Fraction' DESC LIMIT 100
### Instruction: What are the payment dates for any payments that have an amount greater than 10 or were handled by a staff member with the first name Elsa, and count them by a line chart, and order in ascending by the X. ### Response:
SELECT payment_date, COUNT(payment_date) FROM payment WHERE amount > 10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Elsa' GROUP BY payment_date ORDER BY payment_date
### Instruction: has patient 013-29856 been diagnosed with a disease in their last 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 = '013-29856' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1))
### Instruction: Top 500 users from the Netherlands. Lists the top 500 users (ranked by reputation) that are located in the Netherlands based on their profile info ### Response:
SELECT RANK() OVER (ORDER BY Reputation DESC) AS "Rank", Id AS "user_link", Reputation, WebsiteUrl, Location FROM Users WHERE Location LIKE '%Netherlands%' OR Location LIKE '%Holland%' OR Location LIKE N'%Amsterdam%' OR (Location LIKE N'%NL%' AND NOT Location LIKE N'%finland%') ORDER BY Reputation DESC LIMIT 500
### Instruction: how many oth extraoc mus-tend op procedures were performed this year? ### 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 = 'oth extraoc mus-tend op') AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: Questions with answers more than 5. ### Response:
SELECT Q.Id AS QId, Q.Title AS QTitle, Q.Body AS QBody, G.Id AS GId, G.Body AS GBody, Q.Score AS QScore, G.Score AS GScore, Q.ViewCount AS QViewCount, G.ViewCount AS GViewCount, Q.Tags AS QTags, G.Title AS GTitle FROM Posts AS G, (SELECT * FROM Posts WHERE ParentId IS NULL AND AnswerCount >= 5) AS Q WHERE G.ParentId = Q.Id
### Instruction: what is the diagnosis cost of poisoning-barbiturates? ### 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 = 'poisoning-barbiturates'))
### Instruction: what is the number of patients whose discharge location is disc-tran cancer/chldrn h and diagnoses long title is unspecified osteomyelitis, other specified sites? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.discharge_location = "DISC-TRAN CANCER/CHLDRN H" AND diagnoses.long_title = "Unspecified osteomyelitis, other specified sites"
### Instruction: What are the names of the courses Prof. Trevor Legassick teaches ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Trevor Legassick%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: how much does diagnosing long-term use of insulin 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 = 'long-term use of insulin'))
### Instruction: tell me the length of stay of patient 025-53970'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 = '025-53970') AND NOT patient.unitadmittime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: Top users by tag overall. ### Response:
SELECT us.*, tuser.Score FROM Users AS us JOIN (SELECT Answers.OwnerUserId AS UserId, SUM(Answers.Score) AS Score FROM Tags JOIN PostTags ON Tags.Id = PostTags.TagId JOIN Posts ON Posts.Id = PostTags.PostId JOIN Posts AS Answers ON Answers.ParentId = Posts.Id WHERE Tags.TagName = '##TagName##' GROUP BY Answers.OwnerUserId) AS tuser ON tuser.UserId = us.Id ORDER BY Score DESC
### Instruction: provide the number of patients whose primary disease is st-segment elevation myocardial infarction\cardiac cath and procedure short title is attach pedicle graft nec? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "ST-SEGMENT ELEVATION MYOCARDIAL INFARCTION\CARDIAC CATH" AND procedures.short_title = "Attach pedicle graft NEC"
### Instruction: Posts with YouTube links on Music Fans. ### Response:
SELECT COUNT(*) AS aantal, HasYouTube, PostType FROM (SELECT p.Id AS PostId, CASE WHEN p.Body LIKE '%youtube.com%' OR p.Body LIKE '%youtu.be%' OR p.Body LIKE '%soundcloud.com%' THEN 1 ELSE 0 END AS HasYouTube, pt.Name AS PostType FROM Posts AS p LEFT JOIN PostTypes AS pt ON pt.Id = p.PostTypeId) AS pp GROUP BY HasYouTube, PostType ORDER BY PostType, HasYouTube DESC
### Instruction: what was the total amount of input of patient 11362 on the first intensive care unit visit? ### Response:
SELECT SUM(inputevents_cv.amount) 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 = 11362) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1)
### Instruction: How many Migration (per 1,000) has a Crude birth rate (per 1,000) of 17.54 and a Natural change (per 1,000) larger than 10.95? ### Response:
SELECT SUM("Migration (per 1,000)") FROM table_42588 WHERE "Crude birth rate (per 1,000)" = '17.54' AND "Natural change (per 1,000)" > '10.95'
### Instruction: was patient 006-40255 receiving since 5 years ago any medication? ### 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 = '006-40255')) AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-5 year')
### Instruction: give me the number of patients whose diagnoses long title is intestinal infection due to clostridium difficile and lab test category is blood gas? ### 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 = "Intestinal infection due to Clostridium difficile" AND lab."CATEGORY" = "Blood Gas"
### Instruction: Get the number of patients with coronary artery disease or coronary artery bypass graft myomectomy/sda primary disease who had a urine lab test. ### 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 = "Urine"
### Instruction: does patient 017-36245 have any diagnosis of a disease 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 = '017-36245')) AND STRFTIME('%y', diagnosis.diagnosistime) <= '2104'
### Instruction: Positive scored questions, with multiple, all-negative answers, no accepted answer. ### Response:
SELECT Q.Id AS "post_link", COUNT(*) AS ANum, SUM(CASE WHEN A.Score < 0 THEN 1 ELSE 0 END) AS ANegNum FROM Posts AS Q, Posts AS A WHERE A.ParentId = Q.Id AND Q.Score > 0 AND Q.AcceptedAnswerId IS NULL GROUP BY Q.Id HAVING COUNT(*) = SUM(CASE WHEN A.Score < 0 THEN 1 ELSE 0 END) ORDER BY Q.Id 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, give me the comparison about the sum of salary over the hire_date bin hire_date by weekday by a bar chart. ### Response:
SELECT HIRE_DATE, SUM(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: what are the four most common intakes since 6 years ago? ### 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(), '-6 year') GROUP BY inputevents_cv.itemid) AS t1 WHERE t1.c1 <= 4)
### Instruction: List UI5 related questions for a user. ### Response:
SELECT Title, Posts.CreationDate, AcceptedAnswerId, Tags, Posts.Id AS "post_link" FROM Posts INNER JOIN PostTags ON PostTags.PostId = Posts.Id INNER JOIN Tags ON Tags.Id = PostTags.TagId INNER JOIN Users ON Users.Id = Posts.OwnerUserId WHERE PostTypeId = 1 AND DisplayName = '##Username:string##' AND TagName = '##Tagname:string?sapui5##' ORDER BY Posts.CreationDate DESC
### Instruction: What are the papers of saurabh gupta in instance segmentation ? ### Response:
SELECT DISTINCT author.authorid, paper.paperid FROM author, keyphrase, paper, paperkeyphrase, writes WHERE author.authorname = 'saurabh gupta' AND keyphrase.keyphrasename = 'instance segmentation' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
### Instruction: Time distribution of unclosed questions - weekly on a given year. ### Response:
SELECT DATE(STR(YEAR(q.CreationDate)) + '-' + STR(MONTH(q.CreationDate)) + '-' + STR(DAY(q.CreationDate))) AS FullDate, COUNT(*) AS Total FROM Posts AS q WHERE q.PostTypeId = 1 GROUP BY STR(YEAR(q.CreationDate)) + '-' + STR(MONTH(q.CreationDate)) + '-' + STR(DAY(q.CreationDate)) ORDER BY FullDate
### Instruction: what was the last time until 48 months ago patient 4718 was prescribed a medication via a tt route? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 4718) AND prescriptions.route = 'tt' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-48 month') ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: Graph: No accepted/upvoted answers by date. ### Response:
SELECT DATE(q.CreationDate), COUNT(DATE(q.CreationDate)) FROM Posts AS q WHERE q.PostTypeId = 1 AND q.AcceptedAnswerId IS NULL AND q.ClosedDate IS NULL AND COALESCE((SELECT MAX(a.Score) FROM Posts AS a WHERE a.ParentId = q.Id AND a.PostTypeId = 2), 0) <= 0 GROUP BY DATE(q.CreationDate) ORDER BY DATE(q.CreationDate)
### Instruction: maxium minutes of suggested-edit before final. ### Response:
SELECT MAX(CAST((JULIANDAY(COALESCE(ApprovalDate, RejectionDate)) - JULIANDAY(CreationDate)) AS INT)) AS "max_hours", AVG(CAST((JULIANDAY(COALESCE(ApprovalDate, RejectionDate)) - JULIANDAY(CreationDate)) AS INT)) AS "avg_hours" FROM SuggestedEdits WHERE NOT ApprovalDate IS NULL OR NOT RejectionDate IS NULL
### 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: how many hours has elapsed since patient 025-50213 stayed in ward 927 for the last time in the in their current hospital encounter? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '025-50213' AND patient.wardid = 927 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime DESC 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: tell me the length of stay of patient 006-93519's first 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-93519') AND NOT patient.unitadmittime IS NULL ORDER BY patient.unitadmittime LIMIT 1
### 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: count the number of patients whose diagnoses long title is malignant carcinoid tumor of the rectum and lab test category is hematology? ### 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 = "Malignant carcinoid tumor of the rectum" AND lab."CATEGORY" = "Hematology"
### 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 much insulin had been prescribed to patient 3929 in total this month? ### Response:
SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3929) AND prescriptions.drug = 'insulin' AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: the number of patients who have received a treatment of hyperkalemia - intravenous calcium procedure during this year. ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'treatment of hyperkalemia - intravenous calcium' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))