instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: in 2103, what were the four 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 STRFTIME('%y', intakeoutput.intakeoutputtime) = '2103' GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 4
### Instruction: show me the flights on TW from ATLANTA in the morning ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service, city, flight WHERE (city.city_code = airport_service.city_code AND city.city_name = 'ATLANTA' AND flight.airline_code = 'TW' AND flight.from_airport = airport_service.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
### Instruction: retrieve the top five most common specimens tested since 4 years ago? ### Response:
SELECT t1.culturesite FROM (SELECT microlab.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microlab WHERE DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY microlab.culturesite) AS t1 WHERE t1.c1 <= 5
### Instruction: how many patients have a diagnosis of malignant neoplastic bladder nec along with joint fluid lab test done? ### 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 = "Malig neo bladder NEC" AND lab.fluid = "Joint Fluid"
### 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 email and manager_id in a bar chart, and order y-axis in ascending order. ### Response:
SELECT EMAIL, 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 are the five most frequent events in the output until 2102? ### Response:
SELECT t1.celllabel FROM (SELECT intakeoutput.celllabel, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM intakeoutput WHERE intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y', intakeoutput.intakeoutputtime) <= '2102' GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 5
### Instruction: What is the average 2001 value with a 2010 value greater than 414, a 2011 value of 7192, and a 2005 value larger than 7340? ### Response:
SELECT AVG("2001") FROM table_70545 WHERE "2010" > '414' AND "2011" = '7192' AND "2005" > '7340'
### Instruction: Show the ids and names of festivals that have at least two nominations for artworks Plot them as bar chart, could you show by the X-axis from low to high? ### Response:
SELECT T3.Festival_Name, T1.Festival_ID FROM nomination AS T1 JOIN artwork AS T2 ON T1.Artwork_ID = T2.Artwork_ID JOIN festival_detail AS T3 ON T1.Festival_ID = T3.Festival_ID ORDER BY T3.Festival_Name
### Instruction: Percentage of tags with wikis by site. See which sites are most conscientious about writing tag wikis. ### Response:
SELECT COUNT(t.Id) AS "all_tags", COUNT(t2.Id) AS "tags_with_excerpt", 100.0 * COUNT(t2.Id) / COUNT(t.Id) AS "percent" FROM Tags AS t LEFT JOIN Tags AS t2 ON t.Id = t2.Id AND NOT t2.ExcerptPostId IS NULL
### Instruction: how many patients are diagnosed for atrioventricular block complete and were suggested to replace the drug route? ### 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 = "Atrioventricular block, complete" AND prescriptions.route = "REPLACE"
### Instruction: what is the constellation when the object type is spiral galaxy, the ngc number is less than 3593 and the right ascension (j2000) is 11h05m48.9s? ### Response:
SELECT constellation FROM table_name_24 WHERE object_type = "spiral galaxy" AND ngc_number < 3593 AND right_ascension___j2000__ = "11h05m48.9s"
### Instruction: during this year, how many patients were prescribed sodium citrate/citric acid? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT prescriptions.hadm_id FROM prescriptions WHERE prescriptions.drug = 'sodium citrate/citric acid' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
### Instruction: How many patients have a diagnoses short title of twin-mate lb-in hos w cs and lab test abnormal status of 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.short_title = "Twin-mate lb-in hos w cs" AND lab.flag = "abnormal"
### Instruction: count the number of patients whose diagnoses icd9 code is 35981 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.icd9_code = "35981" AND prescriptions.drug_type = "BASE"
### 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 job_id and department_id , and sort in descending by the y axis. ### Response:
SELECT JOB_ID, 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 DESC
### Instruction: count the number of patients whose diagnoses icd9 code is 28860 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.icd9_code = "28860" AND prescriptions.drug_type = "BASE"
### Instruction: what number of patients admitted before the 2200 had the diagnoses titled pseudomonas infection in conditions classified elsewhere and of unspecified site? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2200" AND diagnoses.long_title = "Pseudomonas infection in conditions classified elsewhere and of unspecified site"
### Instruction: count the number of patients whose diagnoses icd9 code is 78659 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.icd9_code = "78659" AND lab."CATEGORY" = "Blood Gas"
### Instruction: How many products have the color description 'red' and the characteristic name 'slow'? ### Response:
SELECT COUNT(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN characteristics AS t3 ON t2.characteristic_id = t3.characteristic_id JOIN ref_colors AS t4 ON t1.color_code = t4.color_code WHERE t4.color_description = "red" AND t3.characteristic_name = "slow"
### Instruction: Socket of fcbga1088, and a Voltage of 1v, and a Part number(s) of nu80579ez600cnu80579ez600ct is what mult? ### Response:
SELECT mult FROM table_name_3 WHERE socket = "fcbga1088" AND voltage = "1v" AND part_number_s_ = "nu80579ez600cnu80579ez600ct"
### Instruction: count the number of patients whose diagnoses short title is iatrogen cv infarc/hmrhg and lab test fluid is blood? ### 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 = "Iatrogen CV infarc/hmrhg" AND lab.fluid = "Blood"
### Instruction: count the number of patients whose diagnoses icd9 code is 53081 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.icd9_code = "53081" AND lab."CATEGORY" = "Hematology"
### Instruction: how many patients are diagnosed with non rupt cerebral aneurym and tested for hematology in lab? ### 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 = "Nonrupt cerebral aneurym" AND lab."CATEGORY" = "Hematology"
### Instruction: how many patients are diagnosed with primary disease atrial fibrillation\thoracoscopic maze procedure bilateral/sda and died before 2115? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "ATRIAL FIBRILLATION\THORACOSCOPIC MAZE PROCEDURE BILATERAL/SDA" AND demographic.dod_year <= "2115.0"
### Instruction: provide the number of patients whose diagnoses icd9 code is 30390 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.icd9_code = "30390" AND lab."CATEGORY" = "Blood Gas"
### Instruction: For those employees who was hired before 2002-06-21, draw a bar chart about the distribution of hire_date and the average of employee_id bin hire_date by time, and I want to sort y-axis from low to high order. ### Response:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(EMPLOYEE_ID)
### Instruction: Which GDP per capita (US$) (2004) has a Literacy (2003) of 90%, and an Area (km ) of 1247689.5? ### Response:
SELECT AVG("GDP per capita (US$) (2004)") FROM table_48075 WHERE "Literacy (2003)" = '90%' AND "Area (km\u00b2)" = '1247689.5'
### 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 email and manager_id in a bar chart, and could you order x-axis from low to high order? ### Response:
SELECT EMAIL, MANAGER_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMAIL
### Instruction: Find the names of catalog entries with level number 8, and count them by a bar chart, and rank in descending by the y axis. ### Response:
SELECT catalog_entry_name, COUNT(catalog_entry_name) FROM Catalog_Contents AS t1 JOIN Catalog_Contents_Additional_Attributes AS t2 ON t1.catalog_entry_id = t2.catalog_entry_id WHERE t2.catalog_level_number = "8" GROUP BY catalog_entry_name ORDER BY COUNT(catalog_entry_name) DESC
### Instruction: give me the number of patients whose diagnoses icd9 code is 69514 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.icd9_code = "69514" AND lab."CATEGORY" = "Chemistry"
### Instruction: RabbitMQ Versus ActiveMQ. Popularity Over Time.. ### Response:
SELECT COUNT(*) AS count, TagName, TIME_TO_STR(CreationDate, '%Y') AS year FROM PostTags INNER JOIN Tags ON Tags.Id = TagId INNER JOIN Posts ON Posts.Id = PostId WHERE TagName IN ('go', 'django', 'node.js') GROUP BY TagName, TIME_TO_STR(CreationDate, '%Y') ORDER BY TIME_TO_STR(CreationDate, '%Y')
### Instruction: what were the three most common specimen tests performed since 2101? ### Response:
SELECT t1.spec_type_desc FROM (SELECT microbiologyevents.spec_type_desc, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microbiologyevents WHERE STRFTIME('%y', microbiologyevents.charttime) >= '2101' GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 3
### Instruction: Questions tagged with [tag] that never got an answer. ### Response:
SELECT Unanswered, Total, (Unanswered / Total) AS Percentage FROM (SELECT COUNT(Id) AS Unanswered, (SELECT COUNT(Id) FROM Posts WHERE PostTypeId = 1 AND STR_POSITION(Tags, @tag1) > 0) AS Total FROM Posts WHERE PostTypeId = 1 AND STR_POSITION(Tags, @tag1) > 0 AND AnswerCount = 0) AS dataQuery
### Instruction: usage of with in data.table answers. ### Response:
SELECT CONCAT('https://stackoverflow.com/a/', CAST(Id AS TEXT)) FROM Posts WHERE ParentId IN (SELECT DISTINCT PostId FROM PostTags WHERE TagId = (SELECT Id FROM Tags WHERE TagName = 'data.table')) AND PostTypeId = 2 AND (Body LIKE '%with=F%' OR Body LIKE '%with =F%' OR Body LIKE '%with= F%' OR Body LIKE '%with = F%') AND NOT Body LIKE '%..%'
### Instruction: count the number of patients whose marital status is married and diagnoses long title is mechanical complication due to other implant and internal device, not elsewhere classified? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.marital_status = "MARRIED" AND diagnoses.long_title = "Mechanical complication due to other implant and internal device, not elsewhere classified"
### Instruction: count the number of patients who since 4 years ago have been prescribed simvastatin 40 mg po tabs. ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT medication.patientunitstayid FROM medication WHERE medication.drugname = 'simvastatin 40 mg po tabs' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-4 year'))
### Instruction: Which Effic is the average one that has an Avg/G larger than 3.7, and a GP-GS of 13, and a Cmp-Att-Int of 318-521-15? ### Response:
SELECT AVG("Effic") FROM table_36930 WHERE "Avg/G" > '3.7' AND "GP-GS" = '13' AND "Cmp-Att-Int" = '318-521-15'
### Instruction: Give me a stacked bar chart to show how many things in different types of each thing, and the details of the organization that owns it, list by the total number in asc. ### Response:
SELECT Type_of_Thing_Code, COUNT(Type_of_Thing_Code) FROM Things AS T1 JOIN Organizations AS T2 ON T1.organization_id = T2.organization_id GROUP BY organization_details, Type_of_Thing_Code ORDER BY COUNT(Type_of_Thing_Code)
### Instruction: find the number of patients diagnosed with ulcer of other part of foot who are on base type drug prescription. ### 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 = "Ulcer of other part of foot" AND prescriptions.drug_type = "BASE"
### Instruction: Who was the best blocker for the year that has a League Champion of queens of pain, and a C.A.N.T.S.L.E.E.P. Award of chassis crass (brooklyn)? ### Response:
SELECT "Best Blocker" FROM table_64957 WHERE "League Champion" = 'queens of pain' AND "C.A.N.T.S.L.E.E.P. Award" = 'chassis crass (brooklyn)'
### Instruction: had a microbiology test been done in the first hospital visit on the blood culture of patient 96006? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 96006 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND microbiologyevents.spec_type_desc = 'blood culture'
### Instruction: How many patients are diagnosed with noninf gastroenterit nec and received medication through oral drug route? ### 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 = "Noninf gastroenterit NEC" AND prescriptions.route = "ORAL"
### Instruction: what was the last ward id that patient 27739 went since 3 years ago? ### Response:
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27739) AND NOT transfers.wardid IS NULL AND DATETIME(transfers.intime) >= DATETIME(CURRENT_TIME(), '-3 year') ORDER BY transfers.intime DESC LIMIT 1
### Instruction: How many patients were diagnosed with abnormal reaction to surgery or procedure and have their lab test category as 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.short_title = "Abn react-surg proc NEC" AND lab."CATEGORY" = "Chemistry"
### Instruction: when was the first time that liposomal cytarabine (depocyt) was prescribed to patient 64538? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 64538) AND prescriptions.drug = 'liposomal cytarabine (depocyt)' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Give the number of patients diagnosed under icd9 code 769 that have additive as the drug type ### 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 = "769" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: tell me the total amount of patient 31854's inputs on the current icu 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 = 31854) AND icustays.outtime IS NULL)
### Instruction: what were the top three procedures for patients 20s? ### Response:
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 20 AND 29) GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3
### Instruction: when is the last time patient 9566 was prescribed a drug since 07/2105? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9566) AND STRFTIME('%y-%m', prescriptions.startdate) >= '2105-07' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: How many emergency hospital admission patients have calculus of bile duct without mention of cholecystitis or obstruction diagnoses? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND diagnoses.long_title = "Calculus of bile duct without mention of cholecystitis, without mention of obstruction"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, for commission_pct, hire_date, visualize the trend, sort X in asc order. ### Response:
SELECT HIRE_DATE, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY HIRE_DATE
### Instruction: provide the number of patients whose procedure long title is intraoperative cardiac pacemaker and lab test category is blood gas? ### 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 = "Intraoperative cardiac pacemaker" AND lab."CATEGORY" = "Blood Gas"
### Instruction: count the number of patients whose discharge location is disc-tran cancer/chldrn h and procedure short title is endosc destr stomach les? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "DISC-TRAN CANCER/CHLDRN H" AND procedures.short_title = "Endosc destr stomach les"
### Instruction: what is the number of patients whose ethnicity is hispanic/latino - puerto rican and lab test name is potassium, whole blood? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND lab.label = "Potassium, Whole Blood"
### Instruction: what is patient 027-211129's last diagnosis? ### Response:
SELECT diagnosis.diagnosisname FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-211129')) ORDER BY diagnosis.diagnosistime DESC LIMIT 1
### Instruction: count the number of patients whose diagnoses short title is ventricular fibrillation and drug route is replace? ### 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 = "Ventricular fibrillation" AND prescriptions.route = "REPLACE"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of hire_date and the sum of department_id bin hire_date by time in a bar chart. ### 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)
### Instruction: A stacked bar about the number of faults for different fault description and fault status of all the faults recoreded in the logs, I want to sort how many fault status in ascending order please. ### Response:
SELECT fault_status, COUNT(fault_status) FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY fault_description, fault_status ORDER BY COUNT(fault_status)
### Instruction: find the number of patients who are diagnosed with postinflammatory pulmonary fibrosis and were ordered urine lab test. ### 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 = "Postinflam pulm fibrosis" AND lab.fluid = "Urine"
### Instruction: What are the register ids of electoral registries that have the cross reference source system code 'Electoral' or 'Tax'? ### Response:
SELECT T1.electoral_register_id FROM electoral_register AS T1 JOIN cmi_cross_references AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id WHERE T2.source_system_code = 'Electoral' OR T2.source_system_code = 'Tax'
### Instruction: Get me the number of patients who have a chemistry lab test category along with diagnoses icd9 code 2760. ### 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.icd9_code = "2760" AND lab."CATEGORY" = "Chemistry"
### Instruction: Who is , was , or will be teaching Information Industry ? ### Response:
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.name LIKE '%Information Industry%'
### Instruction: what was the total number of other myectomy procedures ordered since 5 years ago? ### Response:
SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'other myectomy') AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-5 year')
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me the trend about salary over hire_date with a line chart, order in desc by the x axis. ### Response:
SELECT HIRE_DATE, SALARY 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: What was the Years in competition that had a Premiership of 1982, 1984, 1999, 2002-03, 2008-09-10? ### Response:
SELECT years_in_competition FROM table_name_2 WHERE premiership_years = "1982, 1984, 1999, 2002-03, 2008-09-10"
### Instruction: how many patients with iv drip route of drug administration have diagnosis icd9 code v4281? ### 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 = "V4281" AND prescriptions.route = "IV DRIP"
### Instruction: how many ACL 2012 papers have more than 7 citations ? ### Response:
SELECT DISTINCT (paper.paperid), COUNT(cite.citingpaperid) FROM cite, paper, venue WHERE paper.paperid = cite.citedpaperid AND paper.year = 2012 AND venue.venueid = paper.venueid AND venue.venuename = 'ACL' GROUP BY paper.paperid HAVING COUNT(cite.citingpaperid) > 7
### Instruction: how long was patient 43959's last stay at the icu? ### Response:
SELECT STRFTIME('%j', icustays.outtime) - STRFTIME('%j', icustays.intime) FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 43959) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1
### Instruction: give me the number of patients whose admission type is urgent and procedure long title is endoscopic insertion of stent (tube) into bile duct? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "URGENT" AND procedures.long_title = "Endoscopic insertion of stent (tube) into bile duct"
### Instruction: give me the number of patients whose diagnoses icd9 code is 42831 and lab test fluid is other body fluid? ### 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.icd9_code = "42831" AND lab.fluid = "Other Body Fluid"
### Instruction: Give me the list of patients with diagnoses icd9 code v168 taking a prescribed main drug type. ### 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 = "V168" AND prescriptions.drug_type = "MAIN"
### Instruction: how many patients having diagnosis short title as dmi keto nt st uncntrld have lab test abnormal status as delta? ### 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 = "DMI keto nt st uncntrld" AND lab.flag = "delta"
### 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 scatter chart about the correlation between manager_id and department_id . ### Response:
SELECT MANAGER_ID, DEPARTMENT_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: how many patients that died were diagnosed with ketoacidosis, type i [juvenile type], not stated as uncontrolled? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.expire_flag = "1" AND diagnoses.long_title = "Diabetes with ketoacidosis, type I [juvenile type], not stated as uncontrolled"
### Instruction: What is the number of patients whose diagnosis icd9 code is 2720 and have lab test category 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.icd9_code = "2720" AND lab."CATEGORY" = "Hematology"
### Instruction: since 2104 what was the four most common specimen test? ### Response:
SELECT t1.spec_type_desc FROM (SELECT microbiologyevents.spec_type_desc, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microbiologyevents WHERE STRFTIME('%y', microbiologyevents.charttime) >= '2104' GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 4
### Instruction: count the number of patients whose diagnoses icd9 code is e9300 and drug type is main? ### 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 = "E9300" AND prescriptions.drug_type = "MAIN"
### Instruction: get the number of patients who have delta abnormal lab test status and are diagnosed with unspecified diabetic retinopathy. ### 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 = "Diabetic retinopathy NOS" AND lab.flag = "delta"
### 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 line chart about the change of department_id over hire_date . ### Response:
SELECT HIRE_DATE, DEPARTMENT_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: what are the top five most commonly prescribed medicines during this year? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 5
### Instruction: provide the number of patients whose diagnoses icd9 code is v1000 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.icd9_code = "V1000" AND lab."CATEGORY" = "Blood Gas"
### Instruction: how many patients whose diagnoses short title is hx-skin malignancy nec and lab test fluid is pleural? ### 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 = "Hx-skin malignancy NEC" AND lab.fluid = "Pleural"
### Instruction: Stats on questions containing string. ### Response:
SELECT COUNT(Id) AS "Total Count", AVG(Score + 0.0) AS "Avg Score", COUNT(ClosedDate) * 100.0 / COUNT(Id) AS "% Closed" FROM Posts WHERE Posts.PostTypeId = 1 AND Posts.CreationDate >= CURRENT_TIMESTAMP() - 360 AND (LOWER(Posts.Body) LIKE LOWER('%go about this%'))
### Instruction: provide the number of patients whose procedure long title is intraoperative cardiac pacemaker and lab test category is hematology? ### 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 = "Intraoperative cardiac pacemaker" AND lab."CATEGORY" = "Hematology"
### Instruction: Find the name of bank branch that provided the greatest total amount of loans to customers with credit score is less than 100. ### Response:
SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100 GROUP BY T2.bname ORDER BY SUM(T1.amount) DESC LIMIT 1
### Instruction: Low view questions in a tag. ### Response:
SELECT q.Id AS "post_link", CreationDate, ViewCount, Tags, ClosedDate FROM Posts AS q INNER JOIN PostTags AS pt ON q.Id = pt.PostId INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE q.ViewCount <= '##Views:int##' AND q.CreationDate < DATEADD(month, -3, GETDATE()) AND t.TagName = '##Tag:string##' ORDER BY CreationDate DESC
### Instruction: What's the engine capacity when the mpg-UK urban is less than 12.2, the mpg-UK extra urban is less than 18.8 and the mpg-US turban is less than 7.2? ### Response:
SELECT SUM(engine_capacity) FROM table_name_53 WHERE mpg_uk_urban__cold_ < 12.2 AND mpg_uk_extra_urban < 18.8 AND mpg_us_urban < 7.2
### Instruction: Is WRITING 430 available in the Fall of 2015 ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'WRITING' AND course.number = 430 AND semester.semester = 'Fall' AND semester.semester_id = course_offering.semester AND semester.year = 2015
### Instruction: when was the last hospital admission that patient 17694 was admitted since 3 years ago via the transfer from hosp/extram? ### Response:
SELECT admissions.admittime FROM admissions WHERE admissions.subject_id = 17694 AND admissions.admission_location = 'transfer from hosp/extram' AND DATETIME(admissions.admittime) >= DATETIME(CURRENT_TIME(), '-3 year') ORDER BY admissions.admittime DESC LIMIT 1
### Instruction: provide the number of patients whose discharge location is disch-tran to psych hosp and procedure short title is exc/des hrt les, endovasc. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "DISCH-TRAN TO PSYCH HOSP" AND procedures.short_title = "Exc/des hrt les,endovasc"
### Instruction: select TagName from Tags. ### Response:
SELECT T.TagName, T2.TagName FROM Tags AS T JOIN Posts AS P ON (T.WikiPostId = P.Id) LEFT JOIN TagSynonyms AS TS ON (T.TagName = TS.SourceTagName) LEFT JOIN Tags AS T2 ON (TS.TargetTagName = T2.TagName) WHERE (T.TagName LIKE '%android%' OR P.Body LIKE '%android%') OR (T.TagName LIKE '%java%' OR P.Body LIKE '%java%')
### Instruction: What is College/Junior/Club Team (League), when Position is 'Defence', when Nationality is 'Canada', when Round is less than 5, and when Player is 'Josiah Didier'? ### Response:
SELECT "College/junior/club team (league)" FROM table_61547 WHERE "Position" = 'defence' AND "Nationality" = 'canada' AND "Round" < '5' AND "Player" = 'josiah didier'
### Instruction: how many patients diagnosed with pneumococcal pneumonia were administered drug via 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 = "Pneumococcal pneumonia" AND prescriptions.route = "PO/NG"
### Instruction: when did patient 73652 receive a procedure until 1 year ago last? ### Response:
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73652) AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY procedures_icd.charttime DESC LIMIT 1
### Instruction: give me the number of patients whose diagnoses icd9 code is 2767 and drug type is main? ### 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 = "2767" AND prescriptions.drug_type = "MAIN"
### Instruction: how many patients whose year of birth is less than 2035 and diagnoses short title is preterm nec 1750-1999g? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dob_year < "2035" AND diagnoses.short_title = "Preterm NEC 1750-1999g"
### Instruction: For those employees who was hired before 2002-06-21, show me about the distribution of job_id and the average of manager_id , and group by attribute job_id in a bar chart, and show by the total number in ascending. ### Response:
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY AVG(MANAGER_ID)
### Instruction: the number of patients who have been treated with fiberoptic colonoscopy - with biopsy since 4 years ago. ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'fiberoptic colonoscopy - with biopsy' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-4 year'))
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find hire_date and the amount of hire_date bin hire_date by time, and visualize them by a bar chart. ### Response:
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about commission_pct over the phone_number , display by the x axis in asc. ### 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 PHONE_NUMBER