instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: what is the part number(s) when l2 cache is 512 kb, release date is june 2001 and sSpec number is sl5lv, sl5pu, sl6bw, sl6jm? ### Response:
SELECT part_number_s_ FROM table_name_71 WHERE l2_cache = "512 kb" AND release_date = "june 2001" AND sspec_number = "sl5lv, sl5pu, sl6bw, sl6jm"
### 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 phone_number and employee_id in a bar chart, I want to show names in desc order. ### Response:
SELECT PHONE_NUMBER, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY PHONE_NUMBER DESC
### Instruction: What are the first names of all Accounting professors who teach and what are the classrooms of the courses they teach? ### Response:
SELECT T2.emp_fname, T1.class_room FROM class AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN professor AS T3 ON T2.emp_num = T3.emp_num JOIN department AS T4 ON T4.dept_code = T3.dept_code WHERE T4.dept_name = 'Accounting'
### Instruction: what is the number of patients whose admission type is elective and procedure long title is removal of t-tube, other bile duct tube, or liver tube? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND procedures.long_title = "Removal of T-tube, other bile duct tube, or liver tube"
### Instruction: what are the three most common specimen tests performed until 4 years ago? ### 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) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 3
### 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 department_id , and I want to sort from low to high by the total number. ### Response:
SELECT FIRST_NAME, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY DEPARTMENT_ID
### Instruction: How many Map Key has an Area km larger than 14,003 and a Capital City of al mukalla, and a Pop (2004) larger than 1,028,556? ### Response:
SELECT SUM("Map Key") FROM table_76269 WHERE "Area km\u00b2" > '14,003' AND "Capital City" = 'al mukalla' AND "Pop (2004)" > '1,028,556'
### Instruction: what is the average cost of the hospital involving lamotrigine until 2 years ago? ### Response:
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT prescriptions.hadm_id FROM prescriptions WHERE prescriptions.drug = 'lamotrigine') AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.hadm_id) AS t1
### Instruction: the list of the patient ids of patients diagnosed with pleural effusion - transudate by lab analysis last year. ### Response:
SELECT patient.uniquepid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'pleural effusion - transudate by lab analysis' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
### Instruction: when did patient 031-4423 receive a microbiology test first time? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4423')) ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: Almost dead zombie finder on C++ tag. ### Response:
SELECT q.Id AS "post_link", MAX(a.Score) AS "best_answer_score" FROM Posts AS q JOIN Posts AS a ON a.ParentId = q.Id WHERE q.PostTypeId = 1 AND q.AnswerCount > 0 AND q.AcceptedAnswerId IS NULL AND a.PostTypeId = 2 AND q.Tags LIKE 'c++' GROUP BY q.Id HAVING MAX(a.Score) = 0
### Instruction: What is the total number of white (Hispanic/Non-Hispanic) having a black (Hispanic/Non-Hispanic) of 9.9 and Hispanic under 99.5? ### Response:
SELECT COUNT(white__both_hispanic_and_non_hispanic_) FROM table_name_77 WHERE black__both_hispanic_and_non_hispanic_ = 9.9 AND hispanic__of_any_race_ < 99.5
### Instruction: what was the name of the drug that on this hospital visit patient 021-95970 was allergic to? ### 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 = '021-95970' AND patient.hospitaldischargetime IS NULL))
### Instruction: What are the names of the customers who bought product 'food' at least once? ### Response:
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T4.product_name = "food" GROUP BY T1.customer_id HAVING COUNT(*) >= 1
### Instruction: count the number of patients whose admission type is elective and diagnoses long title is acute glomerulonephritis with other specified pathological lesion in kidney? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND diagnoses.long_title = "Acute glomerulonephritis with other specified pathological lesion in kidney"
### Instruction: what is the first care unit of patient 73713 during this year? ### Response:
SELECT transfers.careunit FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73713) AND NOT transfers.careunit IS NULL AND DATETIME(transfers.intime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY transfers.intime LIMIT 1
### Instruction: what were the five most frequently taken specimen tests until 4 years ago? ### 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) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 5
### Instruction: What is the highest w plyf with a first yr before 1960, a G plyf greater than 0, a G > .500 less than 43, and a w-l% less than 0.578? ### Response:
SELECT MAX(w_plyf) FROM table_name_99 WHERE first_yr < 1960 AND g_plyf > 0 AND g_ > _500 < 43 AND w_l_percentage < 0.578
### Instruction: acl papers in 2016 about Semantic Parsing ### Response:
SELECT DISTINCT paper.paperid FROM keyphrase, paper, paperkeyphrase, venue WHERE keyphrase.keyphrasename = 'Semantic Parsing' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND paper.year = 2016 AND venue.venueid = paper.venueid AND venue.venuename = 'acl'
### Instruction: For the MDE requirement , which courses in Conscious Sedation do I need to take ? ### 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 '%Conscious Sedation%' OR course.description LIKE '%Conscious Sedation%' OR course.name LIKE '%Conscious Sedation%') AND program_course.category LIKE '%MDE%'
### Instruction: provide me with the top three most common intake since 2 years ago? ### 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) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 3
### Instruction: whats the first height of patient 007-8317 during their first hospital encounter? ### Response:
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-8317' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1) AND NOT patient.admissionheight IS NULL ORDER BY patient.unitadmittime LIMIT 1
### Instruction: how many patients whose diagnoses long title is malignant neoplasm of other sites of tongue and drug route is nu? ### 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 = "Malignant neoplasm of other sites of tongue" AND prescriptions.route = "NU"
### Instruction: A bar chart for showing the number of the names of editors that are on the committee of journals with sales bigger than 3000, and could you list from high to low by the Name? ### Response:
SELECT Name, COUNT(Name) FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID WHERE T3.Sales > 3000 GROUP BY Name ORDER BY Name DESC
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, a line chart shows the change of department_id over hire_date, could you order by the HIRE_DATE in desc? ### Response:
SELECT HIRE_DATE, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY HIRE_DATE DESC
### Instruction: had patient 007-2001 undergone anticonvulsant - phenytoin? ### 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 = '007-2001')) AND treatment.treatmentname = 'anticonvulsant - phenytoin'
### Instruction: how much bag is prescribed to patient 9338 in total until 07/2104? ### Response:
SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9338) AND prescriptions.drug = 'bag' AND STRFTIME('%y-%m', prescriptions.startdate) <= '2104-07'
### Instruction: what topics does oren etzioni write about most ? ### Response:
SELECT DISTINCT COUNT(paperkeyphrase.keyphraseid), paperkeyphrase.keyphraseid FROM author, paper, paperkeyphrase, writes WHERE author.authorname = 'oren etzioni' AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid GROUP BY paperkeyphrase.keyphraseid ORDER BY COUNT(paperkeyphrase.keyphraseid) DESC
### Instruction: count the number of patients whose diagnosis short title is chr syst/diastl hrt fail and drug route is left eye. ### 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.route = "LEFT EYE"
### Instruction: [Microsoft AAD B2C] Average answer response time in hours MoM. ### Response:
SELECT P.Id AS PostID, P.Title, P.Body FROM Posts AS P INNER JOIN Posts AS A ON P.AcceptedAnswerId = A.Id INNER JOIN PostTags AS PT ON P.Id = PT.PostId INNER JOIN Tags AS T ON T.Id = PT.TagId WHERE T.TagName LIKE 'azure-ad-b2c' AND P.Score > -1 AND P.PostTypeId = 1
### Instruction: How many times has a user been wrong?. How bad of a user are YOU?! ### Response:
SELECT COUNT(*) FROM Votes AS v INNER JOIN Posts AS p ON v.PostId = p.Id WHERE (v.VoteTypeId = 3 OR v.VoteTypeId = 4 OR v.VoteTypeId = 6 OR v.VoteTypeId = 10 OR v.VoteTypeId = 12 OR v.VoteTypeId = 15) AND p.OwnerUserId = @UserId
### Instruction: what were the five most frequent specimen tests performed since 6 years ago? ### 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) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 5
### Instruction: tell me what the top five most commonly prescribed drugs are during the previous year? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of first_name and manager_id , I want to rank in asc by the y-axis. ### Response:
SELECT FIRST_NAME, MANAGER_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY MANAGER_ID
### Instruction: What was the percentage in 1980 that had less than 37.8% in 2006, more than 29.4% in 2000, and more than 18.2% in 1970? ### Response:
SELECT MIN("1980") FROM table_49438 WHERE "2006" < '37.8' AND "2000" > '29.4' AND "1970" > '18.2'
### Instruction: Show the number of courses for each course description in a bar chart, could you order bar from high to low 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 CRS_DESCRIPTION ORDER BY CRS_DESCRIPTION DESC
### Instruction: what are the top four of the most frequent output event in 2100? ### 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 STRFTIME('%y', outputevents.charttime) = '2100' GROUP BY outputevents.itemid) AS t1 WHERE t1.c1 <= 4)
### Instruction: For the dates of transactions with amount smaller than 3000, bin the date into year interval, and draw a line chart to show the trend of the number of records in each bin, rank x axis from high to low order please. ### Response:
SELECT date_of_transaction, COUNT(date_of_transaction) FROM Sales AS T1 JOIN Transactions AS T2 ON T1.sales_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction < 3000 ORDER BY date_of_transaction DESC
### Instruction: What courses is Prof. Earl Werner the teacher of ? ### 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 '%Earl Werner%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: What is the total number of 13.5 inch/1400 lb that has a 0 13.5 inch/1250 lb; 3 for a total and a 15 inch less than 1? ### Response:
SELECT COUNT("13.5-inch/1400lb") FROM table_42805 WHERE "13.5-inch/1250lb" = '0' AND "Total" = '3' AND "15-inch" < '1'
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find email and commission_pct , and visualize them by a bar chart, I want to sort X-axis from high to low order please. ### Response:
SELECT EMAIL, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMAIL DESC
### Instruction: what is the number of patients whose diagnoses short title is perinat gi sys dis nec and drug route is po/ng? ### 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 = "Perinat GI sys dis NEC" AND prescriptions.route = "PO/NG"
### Instruction: until 2102 what were the four most common lab tests? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t1.itemid FROM (SELECT labevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM labevents WHERE STRFTIME('%y', labevents.charttime) <= '2102' GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 4)
### Instruction: Separate a post in id, title, question and answers for given post Id. Example input: 3006643,2106715,1429318 (.csv downloadable for about 200 PostID's) ### Response:
SELECT p.Id, p.Title, p.Body, k.Body FROM Posts AS p INNER JOIN Posts AS k ON p.Id = k.ParentId WHERE p.Id IN ('##id##') AND k.PostTypeId = 2
### Instruction: when was the last hospital admission that patient 027-130381 was admitted to via the operating room until 4 years ago? ### Response:
SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '027-130381' AND patient.hospitaladmitsource = 'operating room' AND DATETIME(patient.hospitaladmittime) <= DATETIME(CURRENT_TIME(), '-4 year') ORDER BY patient.hospitaladmittime DESC LIMIT 1
### Instruction: All answers with a given tag. ### Response:
SELECT a.ParentId AS "id", a.Score AS "sc", CONCAT(a.OwnerDisplayName, u.DisplayName) AS "au", a.Body AS "body" FROM Posts AS a LEFT JOIN Users AS u ON a.OwnerUserId = u.Id WHERE EXISTS(SELECT q.Id FROM Posts AS q WHERE q.Id = a.ParentId AND q.Tags LIKE '%<##Tag##>%' AND u.DisplayName = 'Maxim') ORDER BY a.ParentId
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of last_name and commission_pct , could you order by the X-axis from low to high? ### Response:
SELECT LAST_NAME, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY LAST_NAME
### Instruction: had there been any organism found in patient 15821's last sputum microbiology test? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15821) AND microbiologyevents.spec_type_desc = 'sputum' AND NOT microbiologyevents.org_name IS NULL ORDER BY microbiologyevents.charttime DESC LIMIT 1
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about employee_id over the last_name by a bar chart, and could you display by the bar in desc please? ### Response:
SELECT LAST_NAME, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY LAST_NAME DESC
### 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 phone_number and commission_pct , list in asc by the Y-axis please. ### Response:
SELECT PHONE_NUMBER, 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
### Instruction: Bounties (potentially) in grace period. ### Response:
SELECT pn.PostId AS "post_link" FROM PostNotices AS pn INNER JOIN PostNoticeTypes AS pnt ON pn.PostNoticeTypeId = pnt.Id WHERE pnt.ClassId = 2 AND pn.CreationDate BETWEEN DATEADD(DAY, -8, GETDATE()) AND DATEADD(DAY, -7, GETDATE()) AND pn.DeletionDate IS NULL AND NOT '##seed:int##' IS NULL
### Instruction: Which instructor teaches SOC 324 ? ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'SOC' AND course.number = 324 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: what do rad subtot pancreatectom costs? ### 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 = 'rad subtot pancreatectom'))
### Instruction: WHAT ARE THE HIGHEST POINTS WITH GOALS LARGER THAN 48, WINS LESS THAN 19, GOALS AGAINST SMALLER THAN 44, DRAWS LARGER THAN 5? ### Response:
SELECT MAX("Points") FROM table_61005 WHERE "Goals for" > '48' AND "Wins" < '19' AND "Goals against" < '44' AND "Draws" > '5'
### Instruction: Questions with version-specific tag lacking the generic tag. Find questions that lack the generic tag while having a version-specific one. Suitable for retaggers :) ### Response:
SELECT Tags, Title, AcceptedAnswerId, CreationDate, 'http://dba.stackexchange.com/questions/' + CAST(Id AS TEXT) AS URL FROM Posts WHERE Tags LIKE '%' + '##mainTag:string##' + '-%' AND NOT Tags LIKE '%<' + '##mainTag:string##' + '>%' ORDER BY CreationDate DESC
### Instruction: what is the number of patients whose diagnoses short title is fall on stair/step nec and drug route is buccal? ### 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 = "Fall on stair/step NEC" AND prescriptions.route = "BUCCAL"
### Instruction: how many patients born before the year 2129 were diagosed with atrial septal defect\mitral valve replacement;repair atrial-septal defect/sda ? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "ATRIAL SEPTAL DEFECT\MITRAL VALVE REPLACEMENT;REPAIR ATRIAL-SEPTAL DEFECT/SDA" AND demographic.dob_year < "2129"
### Instruction: how many patients of white-russian ethnicity are diagnosed with primary disease coronary artery disease or coronary artery bypass graft myomectomy/sda? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.ethnicity = "WHITE - RUSSIAN" AND demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT; MYOMECTOMY/SDA"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find job_id and employee_id , and visualize them by a bar chart, and rank X-axis in descending order please. ### Response:
SELECT JOB_ID, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY JOB_ID DESC
### Instruction: What is the highest SFC in g/(kN*s) for Rolls-Royce/Snecma Olympus 593 engines and SFCs under 1.195 lb/(lbf*h)? ### Response:
SELECT MAX(sfc_in_g__kn) AS ·s_ FROM table_name_12 WHERE engine_type = "rolls-royce/snecma olympus 593" AND sfc_in_lb__lbf·h_ < 1.195
### Instruction: patient 002-75209 had any #1:? ### Response:
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-75209')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = '#1:'
### Instruction: in 2105 has patient 013-29301 had any procedure? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-29301')) AND STRFTIME('%y', treatment.treatmenttime) = '2105'
### Instruction: Show the names of schools with a total budget amount greater than 100 or a total endowment greater than 10. ### Response:
SELECT T2.school_name FROM budget AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id JOIN endowment AS T3 ON T2.school_id = T3.school_id GROUP BY T2.school_name HAVING SUM(T1.budgeted) > 100 OR SUM(T3.amount) > 10
### Instruction: how many patients categorized under chemistry lab test had continuous invasive mechanical ventilation for less than 96 consecutive hours? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE procedures.long_title = "Continuous invasive mechanical ventilation for less than 96 consecutive hours" AND lab."CATEGORY" = "Chemistry"
### Instruction: give me the number of patients whose diagnoses short title is hx surgery to organs nec and drug type is base? ### 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 = "Hx surgery to organs NEC" AND prescriptions.drug_type = "BASE"
### Instruction: Not an answer' candidates (upgraded). This query attempts to find answers that aren't answers within 2 month Detects thanks, same problem, problem also, @ ### Response:
SELECT Id AS "post_link", Body FROM Posts WHERE (Body LIKE '%hank%' OR Body LIKE 'same problem' OR Body LIKE 'problem also' OR Body LIKE '@') AND PostTypeId = 2 AND Score < 1 AND LENGTH(Body) < 200 ORDER BY LENGTH(Body) LIMIT 500
### Instruction: what is the number of patients whose diagnoses icd9 code is 25040 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.icd9_code = "25040" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: provide the number of patients on additive type drug prescription who have diagnoses icd9 code 51881. ### 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.icd9_code = "51881" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: count the number of patients that were diagnosed until 3 years ago with acute respiratory distress - etiology unknown. ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'acute respiratory distress - etiology unknown' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-3 year'))
### Instruction: What is the average number of comments on my posts, by post score?. For all posts with a given score, this query shows the average number of comments. ### Response:
SELECT t.Score, AVG(t.CommentCount) AS "average_#_of_comments" FROM (SELECT COUNT(c.Id) * 1.0 AS commentCount, p.Score FROM Comments AS c JOIN Posts AS p ON c.PostId = p.Id GROUP BY p.Score, p.Id) AS t GROUP BY Score ORDER BY Score DESC
### Instruction: how many patients whose diagnoses short title is rheumatoid arthritis and lab test name is hematocrit, calculated? ### 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 = "Rheumatoid arthritis" AND lab.label = "Hematocrit, Calculated"
### Instruction: Percentage of Questions with the Accepted Answer @until. ### Response:
SELECT (CAST(COUNT(DISTINCT q.Id) AS FLOAT) / (SELECT COUNT(*) FROM Posts WHERE Posts.CreationDate < @until AND PostTypeId = 1) * 100) AS AcceptedPercentage FROM Posts AS q INNER JOIN Posts AS a ON q.Id = a.ParentId WHERE a.PostTypeId = 2 AND q.CreationDate < @until AND q.PostTypeId = 1
### Instruction: How many patients diagnosed with paroxysmal ventricular tachycardia have a hematology lab test category? ### 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 = "Paroxysmal ventricular tachycardia" AND lab."CATEGORY" = "Hematology"
### Instruction: what was the average sao2 for patient 027-211129. ### Response:
SELECT AVG(vitalperiodic.sao2) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-211129')) AND NOT vitalperiodic.sao2 IS NULL
### Instruction: A bar chart listing the number of faults for different description of skills required to fix them, rank y axis from high to low order. ### Response:
SELECT skill_description, COUNT(skill_description) FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id = T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id GROUP BY skill_description ORDER BY COUNT(skill_description) DESC
### Instruction: What is the preliminaries of the contestant from Massachusetts with an evening gown higher than 8.631, an average less than 8.791, and an interview higher than 8.608? ### Response:
SELECT COUNT("Preliminaries") FROM table_11826 WHERE "Evening Gown" > '8.631' AND "Average" < '8.791' AND "State" = 'massachusetts' AND "Interview" > '8.608'
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, visualize a bar chart about the distribution of last_name and manager_id , could you show in desc by the Y-axis? ### Response:
SELECT LAST_NAME, MANAGER_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY MANAGER_ID DESC
### Instruction: Find the number of hispanic or latino-puerto rican patients who have lide4500i drug code. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND prescriptions.formulary_drug_cd = "LIDE4500I"
### Instruction: Question distribution by the top answer score. ### Response:
WITH TopAnswerScore AS (SELECT q.Id AS question, MAX(a.Score) AS topscore FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id GROUP BY q.Id) SELECT COALESCE(topscore, 0), COUNT(*) AS N FROM Posts AS p INNER JOIN TopAnswerScore AS q ON question = p.Id GROUP BY COALESCE(topscore, 0) ORDER BY COALESCE(topscore, 0)
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find phone_number and department_id , and visualize them by a bar chart, I want to show in desc by the x axis. ### Response:
SELECT PHONE_NUMBER, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY PHONE_NUMBER DESC
### Instruction: what is the number of patients whose diagnosis is chr syst/diastl hrt fail and drug route is iv bolus? ### 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.route = "IV BOLUS"
### Instruction: Number of users which asked a second question after their first one was closed. https://chat.stackexchange.com/transcript/message/49597785#49597785 ### Response:
SELECT T1.Id, postid FROM Users AS T1 INNER JOIN (SELECT p.Id AS postid FROM Posts AS p WHERE p.PostTypeId = 1 ORDER BY p.CreationDate LIMIT 500) AS T2 ON T1.Id = postid ORDER BY T1.Id LIMIT 100
### Instruction: Select Count(*) From Users Grup By Age. ### Response:
SELECT Jahr, SUM(Anzahl) AS Gesamt, MIN(Anzahl) AS minimal, MAX(Anzahl) AS maximal, AVG(Anzahl) AS Schnitt FROM (SELECT YEAR(CreationDate) AS Jahr, MONTH(CreationDate) AS Monat, COUNT(*) AS Anzahl FROM Users AS U1 GROUP BY YEAR(CreationDate), MONTH(CreationDate)) AS T_TAGESANMELDUNG GROUP BY Jahr ORDER BY Jahr
### Instruction: Average Number of Seconds until Approved Response for 2017 Questions. ### Response:
SELECT AVG(CAST((JULIANDAY(ApprovalDate) - JULIANDAY(p.CreationDate)) * 86400.0 AS INT) * 1.0) AS seconds_to_approved_answer FROM SuggestedEdits AS sed LEFT JOIN Posts AS p ON p.Id = sed.PostId WHERE YEAR(p.CreationDate) = '2017'
### Instruction: give me the number of patients whose diagnoses short title is asthma nos w (ac) exac 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.short_title = "Asthma NOS w (ac) exac" AND lab.fluid = "Urine"
### Instruction: hemoglobin < 11 grams ( g ) / dl ( < 110 g / l ) for male subjects and < 10 g / dl ( < 100 g / l ) for female subjects at screening ### Response:
SELECT * FROM table_train_252 WHERE (hemoglobin_a1c_hba1c < 11 AND gender = 'male') OR (hemoglobin_a1c_hba1c < 10 AND gender = 'female')
### Instruction: whats the unabbreviated version of tb lung cavity-exam unkn. ### Response:
SELECT d_icd_diagnoses.long_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'tb lung cavity-exam unkn' UNION SELECT d_icd_procedures.long_title FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'tb lung cavity-exam unkn'
### Instruction: what is the number of patients whose primary disease is brain mass;intracranial hemorrhage and lab test fluid is cerebrospinal fluid (csf)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "BRAIN MASS;INTRACRANIAL HEMORRHAGE" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: What is the number of booking end dates of the apartments with type code 'Duplex' in each year? Return a bar chart, and could you order y axis from high to low order? ### Response:
SELECT booking_end_date, COUNT(booking_end_date) FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.apt_type_code = "Duplex" ORDER BY COUNT(booking_start_date) DESC
### Instruction: what specimen tests were given to patient 031-4987 for the first time? ### Response:
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4987')) ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: when was patient 10266 prescribed a medication via pr route the first time during 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 = 10266 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND prescriptions.route = 'pr' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Find the enrollment date for all the tests that have 'Pass' result, and count them by a bar chart, and I want to display in asc by the Y. ### Response:
SELECT date_of_enrolment, COUNT(date_of_enrolment) FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Pass" ORDER BY COUNT(date_of_enrolment)
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find first_name and employee_id , and visualize them by a bar chart, order from low to high by the bars. ### Response:
SELECT FIRST_NAME, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY FIRST_NAME
### Instruction: What is the yield, neutrons per fission of the group with decay constants less than 0.301, a half-life of 22.72, and a group number larger than 2? ### Response:
SELECT SUM("Yield, Neutrons per Fission") FROM table_71216 WHERE "Decay Constant (s \u22121 )" < '0.301' AND "Half-Life (s)" = '22.72' AND "Group" > '2'
### Instruction: what is average age of patients whose primary disease is coronary artery disease\coronary artery bypass graft with mvr; ? maze and admission year is greater than or equal to 2115? ### Response:
SELECT AVG(demographic.age) FROM demographic WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT WITH MVR; ? MAZE" AND demographic.admityear >= "2115"
### 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 phone_number and employee_id , and list in ascending by the x-axis. ### Response:
SELECT PHONE_NUMBER, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY PHONE_NUMBER
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of phone_number and employee_id , and show y axis in desc order. ### Response:
SELECT PHONE_NUMBER, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMPLOYEE_ID DESC
### Instruction: what is the number of patients that received a promyelocytes test since 2105? ### 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 = 'promyelocytes') AND STRFTIME('%y', labevents.charttime) >= '2105')
### 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 first_name and employee_id , and display by the total number in ascending. ### Response:
SELECT FIRST_NAME, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMPLOYEE_ID
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find first_name and employee_id , and visualize them by a bar chart, rank by the names in desc please. ### Response:
SELECT FIRST_NAME, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY FIRST_NAME DESC