instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: provide me the number of patients taking medication via inhalation who have diagnoses icd9 code 1418. ### 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 = "1418" AND prescriptions.route = "INHALATION"
### Instruction: how many times until 1 year ago patient 006-47961 had visited the intensive care unit? ### Response:
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-47961') AND DATETIME(patient.unitadmittime) <= DATETIME(CURRENT_TIME(), '-1 year')
### Instruction: For those employees who did not have any job in the past, visualize a bar chart about the distribution of job_id and the sum of employee_id , and group by attribute job_id, and could you rank in ascending by the y-axis? ### Response:
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY SUM(EMPLOYEE_ID)
### Instruction: what's the name of the last medication patient 015-54876 was prescribed? ### Response:
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-54876')) ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: count the number of patients whose ethnicity is black/cape verdean and drug code is hydr20/100ns? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "BLACK/CAPE VERDEAN" AND prescriptions.formulary_drug_cd = "HYDR20/100NS"
### Instruction: Number of occurrences of display names lengths. ### Response:
SELECT U.range AS "display_name_length", COUNT(*) AS "number_of_occurences", ROUND((U.range / 600.0) * 100, 1) AS "character_limit_percentage_used" FROM (SELECT LENGTH(REPLACE(DisplayName, ' ', '')) AS range FROM Users WHERE DisplayName != '' AND NOT DisplayName IS NULL) AS U GROUP BY U.range ORDER BY U.range
### Instruction: How many civil liberties 2013 values are associated with a 2010 political rights value of 6, civil liberties 2012 values over 5, and political rights 2011 under 6? ### Response:
SELECT COUNT(civil_liberties_2013) FROM table_name_42 WHERE political_rights_2010 = 6 AND civil_liberties_2012 > 5 AND political_rights_2011 < 6
### Instruction: i'd like to book two flights to WESTCHESTER COUNTY ### Response:
SELECT DISTINCT flight_id FROM flight WHERE to_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'WESTCHESTER COUNTY'))
### Instruction: For those employees who was hired before 2002-06-21, give me the comparison about the average of employee_id over the hire_date bin hire_date by weekday by a bar chart, and display Y-axis in descending order please. ### Response:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(EMPLOYEE_ID) DESC
### Instruction: what is the top four of the frequent input event in 2101? ### 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) = '2101' GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 4
### Instruction: subjects must have been diagnosed with type ii diabetes, with hba1c level >= 7 % and <= 11 % and a fasting glucose level <= 280 mg / dl. ### Response:
SELECT * FROM table_dev_43 WHERE diabetic = 'ii' AND (hemoglobin_a1c_hba1c >= 7 AND hemoglobin_a1c_hba1c <= 11) AND fasting_glucose <= 280
### Instruction: How many patients admitted as clinic referral (premature) were diagnosed with percutaneous transluminal coronary angioplasty status? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND diagnoses.long_title = "Percutaneous transluminal coronary angioplasty status"
### Instruction: for the first time since 06/2101, when was patient 95892 prescribed a drug? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 95892) AND STRFTIME('%y-%m', prescriptions.startdate) >= '2101-06' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: when was patient 80671 prescribed a drug for the last time until 02/2103? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 80671) AND STRFTIME('%y-%m', prescriptions.startdate) <= '2103-02' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: what were the allergies during the current hospital visit that patient 015-58787 had? ### Response:
SELECT allergy.allergyname FROM allergy WHERE allergy.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))
### Instruction: Among patients tested for blood gas, how many of them were diagnosed with coronary athrscl natve vssl? ### 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 = "Crnry athrscl natve vssl" AND lab."CATEGORY" = "Blood Gas"
### Instruction: Are there any Modern English Grammar courses that complete the Other requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (area.area LIKE '%Modern English Grammar%' OR course.description LIKE '%Modern English Grammar%' OR course.name LIKE '%Modern English Grammar%') AND program_course.category LIKE '%Other%'
### Instruction: count the number of times spironolactone had been prescribed to patient 54894 since 5 years ago. ### Response:
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 54894) AND prescriptions.drug = 'spironolactone' AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-5 year')
### Instruction: provide me with the top four most common intake in 2100? ### 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) = '2100' GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 4
### Instruction: what is the first medication that patient 41816 has been prescribed until 07/2102? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 41816) AND STRFTIME('%y-%m', prescriptions.startdate) <= '2102-07' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: what was the three most commonly carried out specimen tests until 2104? ### 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 <= 3
### Instruction: provide the number of patients whose diagnoses short title is wegener's granulomatosis and drug route is sl? ### 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 = "Wegener's granulomatosis" AND prescriptions.route = "SL"
### 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 last_name and department_id , could you sort in ascending by the y-axis? ### Response:
SELECT LAST_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: For those employees who do not work in departments with managers that have ids between 100 and 200, visualize a line chart about the change of salary over hire_date , and I want to order by the X in ascending. ### 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
### 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 , could you sort x-axis from high to low order? ### 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: give a count of the number of intensive care unit visits of patient 027-69449 in 2105. ### Response:
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-69449') AND STRFTIME('%y', patient.unitadmittime) = '2105'
### Instruction: Show names of technicians who are assigned to repair machines with value point more than 70, and count them by a bar chart, order by the y-axis in desc. ### Response:
SELECT Name, COUNT(Name) FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.Machine_ID = T2.Machine_ID JOIN technician AS T3 ON T1.technician_id = T3.technician_id WHERE T2.value_points > 70 GROUP BY Name ORDER BY COUNT(Name) 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, visualize a scatter chart about the correlation between employee_id and department_id . ### Response:
SELECT EMPLOYEE_ID, DEPARTMENT_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: SO - Mobile OS - Windows. ### Response:
SELECT COUNT(*) AS PostCount, YEAR(P.CreationDate), MONTH(P.CreationDate) FROM Posts AS P INNER JOIN PostTags AS PT ON (P.Id = PT.PostId) INNER JOIN Tags AS T ON (PT.TagId = T.Id) WHERE T.TagName LIKE ('windows-phone%') GROUP BY YEAR(P.CreationDate), MONTH(P.CreationDate) ORDER BY 2 DESC, 3 DESC
### Instruction: For those employees who did not have any job in the past, draw a bar chart about the distribution of job_id and the average of employee_id , and group by attribute job_id, display y-axis from high to low order please. ### Response:
SELECT JOB_ID, AVG(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY AVG(EMPLOYEE_ID) DESC
### 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, show by the Y in desc. ### 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 COMMISSION_PCT DESC
### Instruction: give me the three most common output events since 1 year ago? ### 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 DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 3
### Instruction: list of patient ids of patients who were diagnosed with s/p surgical repair of fracture - femur since 5 years ago. ### Response:
SELECT patient.uniquepid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 's/p surgical repair of fracture - femur' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-5 year'))
### Instruction: calculate the number of patients who have had a urine, voided specimen microbiology test since 3 years ago. ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT microlab.patientunitstayid FROM microlab WHERE microlab.culturesite = 'urine, voided specimen' AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-3 year'))
### Instruction: What is the right ascension (J2000) with a Declination (J2000) of 12 43 , is a constellation of dorado, and has an NGC number larger than 2068? ### Response:
SELECT right_ascension___j2000__ FROM table_name_55 WHERE ngc_number > 2068 AND constellation = "dorado" AND declination___j2000__ = "°12′43″"
### Instruction: Find identical titles (no closed questions, different owner). We also show the creation date of the posts. ### Response:
SELECT a.Id AS "post_link", a.CreationDate AS "First Date", b.Id AS "post_link", b.CreationDate AS "Second Date" FROM Posts AS a JOIN Posts AS b ON a.Title = b.Title WHERE a.Id < b.Id AND a.OwnerUserId != b.OwnerUserId AND a.ClosedDate IS NULL AND b.ClosedDate IS NULL
### 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 job_id and manager_id in a bar chart, and sort total number in asc order. ### Response:
SELECT JOB_ID, 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: give me the number of patients whose diagnoses icd9 code is 78321 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 = "78321" AND prescriptions.drug_type = "BASE"
### Instruction: during their current hospital encounter, patient 013-33898 has been allergic to any substance? ### 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 = '013-33898' AND patient.hospitaldischargetime IS NULL))
### 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 job_id and manager_id in a bar chart, and list by the X from low to high. ### Response:
SELECT JOB_ID, MANAGER_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY JOB_ID
### Instruction: Count the number of patients on a main drug type prescription with diagnoses icd9 code 41512. ### 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 = "41512" AND prescriptions.drug_type = "MAIN"
### Instruction: provide the number of patients whose diagnoses short title is idio periph neurpthy nos and drug route is dwell? ### 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 = "Idio periph neurpthy NOS" AND prescriptions.route = "DWELL"
### Instruction: provide the number of hispanic or latino patients who are diagnosed with short title gstr/ddnts nos w/o hmrhg. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "HISPANIC OR LATINO" AND diagnoses.short_title = "Gstr/ddnts NOS w/o hmrhg"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, a bar chart shows the distribution of phone_number and manager_id , and sort by the x-axis in desc. ### Response:
SELECT PHONE_NUMBER, MANAGER_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: 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 phone_number and salary , and could you display by the Y-axis from low to high please? ### Response:
SELECT PHONE_NUMBER, SALARY FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SALARY
### Instruction: what is the last ward id of patient 031-17834 since 3 years ago? ### Response:
SELECT patient.wardid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-17834') AND DATETIME(patient.unitadmittime) >= DATETIME(CURRENT_TIME(), '-3 year') ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: What is the sum amount of fall 05 when fall 08 is more than 5, fall 06 is more than 7, the state is Maryland, and fall 09 is more than 471? ### Response:
SELECT COUNT("Fall 05") FROM table_38831 WHERE "Fall 08" > '5' AND "Fall 06" > '7' AND "States" = 'maryland' AND "Fall 09" > '471'
### Instruction: How many values for 24 mountains when the bearing or degrees is 67.6 - 82.5 82.6 - 97.5 97.6 - 112.5? ### Response:
SELECT COUNT(24 AS _mountains) FROM table_23406517_2 WHERE bearing___degrees = "67.6 - 82.5 82.6 - 97.5 97.6 - 112.5"
### Instruction: Please show the names and descriptions of aircrafts associated with airports that have a total number of passengers bigger than 10000000. ### Response:
SELECT T1.aircraft, T1.description FROM aircraft AS T1 JOIN airport_aircraft AS T2 ON T1.aircraft_id = T2.aircraft_id JOIN airport AS T3 ON T2.airport_id = T3.airport_id WHERE T3.total_passengers > 10000000
### Instruction: What courses in Animal Diversity satisfy the PreMajor requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (area.area LIKE '%Animal Diversity%' OR course.description LIKE '%Animal Diversity%' OR course.name LIKE '%Animal Diversity%') AND program_course.category LIKE '%PreMajor%'
### Instruction: show me the last ward identification of patient 030-40287 until 2 years ago? ### Response:
SELECT patient.wardid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-40287') AND DATETIME(patient.unitadmittime) <= DATETIME(CURRENT_TIME(), '-2 year') ORDER BY patient.unitadmittime DESC LIMIT 1
### 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 job_id and manager_id , and show in desc by the total number. ### Response:
SELECT JOB_ID, 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: what is the Density (per km ) when the Area (km ) is 372,889 and the population (2011) is 1,145,861? ### Response:
SELECT SUM("Density (per km\u00b2)") FROM table_14252 WHERE "Area (km\u00b2)" = '372,889' AND "Population (2011)" > '1,145,861'
### Instruction: how many patients whose insurance is medicare and diagnoses long title is acute myocardial infarction of inferolateral wall, initial episode of care? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.insurance = "Medicare" AND diagnoses.long_title = "Acute myocardial infarction of inferolateral wall, initial episode of care"
### Instruction: retrieve the top five most common output events since 6 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 '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 5
### Instruction: Get the name of tags used in 2011. Query for luckydonald http://stackoverflow.com/questions/34485255/get-each-tag-in-string-stackexchange-database?noredirect ### Response:
SELECT DISTINCT TagName AS Tag FROM PostHistory JOIN Tags ON PostHistory.Text LIKE ('%<' + Tags.TagName + '>%') WHERE YEAR(CreationDate) = 2011 AND PostHistoryTypeId IN (3, 6, 9)
### Instruction: How many patients are diagnosed with other second degree atrioventricular block were suggested the 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.long_title = "Other second degree atrioventricular block" AND prescriptions.route = "ORAL"
### Instruction: what is the number of patients whose diagnoses icd9 code is v1581 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.icd9_code = "V1581" AND prescriptions.route = "PO/NG"
### Instruction: provide me with the top four most common intake in 2102? ### 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) = '2102' GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 4
### Instruction: how many patients have received antiemetic - serotonin antagonist treatment this year? ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'antiemetic - serotonin antagonist' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
### Instruction: how many of the patients with creation of conduit between left ventricle and aorta had a lab test for pleural fluid? ### 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 = "Creation of conduit between left ventricle and aorta" AND lab.fluid = "Pleural"
### Instruction: provide the number of patients on pb route of drug administration who have been diagnosed with toxic encephalopathy. ### 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 = "Toxic encephalopathy" AND prescriptions.route = "PB"
### Instruction: until 2102, what was the four of the most frequent output events? ### 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 <= 4
### Instruction: give the number of patients who are widowed and diagnosed with osteoarthrosis, unspecified whether generalized or localized, site unspecified. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.marital_status = "WIDOWED" AND diagnoses.long_title = "Osteoarthrosis, unspecified whether generalized or localized, site unspecified"
### Instruction: Tags that are 33+ characters long & contain a number. Looks for tags with a length of over 33 characters which also contain a number. Created to locate tags which may exceed 35 characters if title used Roman Numerals. https://gaming.meta.stackexchange.com/q/12181/181240 ### Response:
SELECT TagName FROM Tags WHERE LENGTH(TagName) >= 33 AND TagName LIKE '%0-9%' ORDER BY LENGTH(TagName) DESC
### Instruction: what is the maximum sao2 of patient 025-35599? ### Response:
SELECT MAX(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 = '025-35599')) AND NOT vitalperiodic.sao2 IS NULL
### 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 first_name and department_id in a bar chart, and list X from low to high order. ### 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 FIRST_NAME
### Instruction: provide the number of patients whose drug code is phyt10ivbp and lab test fluid is urine. ### 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 = "PHYT10IVPB" AND lab.fluid = "Urine"
### Instruction: For those employees who was hired before 2002-06-21, find job_id and the sum of department_id , and group by attribute job_id, and visualize them by a bar chart, display by the total number of department id from high to low. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY SUM(DEPARTMENT_ID) DESC
### Instruction: how many patients are diagnosed with short title aftrcre traum fx low leg and have iv route of drug administration? ### 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 = "Aftrcre traum fx low leg" AND prescriptions.route = "IV"
### Instruction: what is the number of patients whose diagnoses icd9 code is 42833 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 = "42833" AND prescriptions.drug_type = "BASE"
### Instruction: Top 100 Java coders from Pakistan. ### Response:
SELECT u.Id AS "user_link", SUM(p.Score) AS ReactScore, u.Reputation, u.Location FROM Users AS u INNER JOIN Posts AS p ON p.OwnerUserId = u.Id WHERE (LOWER(Location) LIKE '%pakistan%' OR UPPER(Location) LIKE '%PK') AND p.Tags LIKE '%java%' GROUP BY u.Id, u.Reputation, u.Location ORDER BY ReactScore DESC LIMIT 100
### Instruction: how many patients diagnosed with short title ac vasc insuff intestine have had lab test belonging to the category 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.short_title = "Ac vasc insuff intestine" AND lab."CATEGORY" = "Blood Gas"
### Instruction: Number of questions asked in an average day about Django. ### Response:
SELECT DATEPART(hour, Posts.CreationDate) AS "daytime", COUNT(Posts.Id) AS "numanswers" FROM Posts INNER JOIN PostTags ON Posts.Id = PostTags.PostId WHERE PostTags.TagId = 243 AND Posts.PostTypeId = 1 AND Posts.CreationDate > DATEADD(year, -1, GETDATE()) GROUP BY DATEPART(hour, Posts.CreationDate)
### Instruction: give me the number of patients whose diagnoses icd9 code is 41031 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 = "41031" AND prescriptions.drug_type = "BASE"
### Instruction: Search my own answer posts.... This query returns the linked list of your answers partially matching the entered body text. Search is not case sensitive. The UserID parameter is your user ID (by default prefilled with your user ID) and the PostText is the text which you want to search for. ### Response:
SELECT Id AS "post_link", Score AS "score", CreationDate AS "creation_date" FROM Posts WHERE OwnerUserId = @MyUserID AND PostTypeId IN (2, 3) ORDER BY CreationDate DESC
### Instruction: *Some* of the cases where LastEditor is blank and not the same as OP. This query probably misses the scenario where both the OP and the last editor are deleted, but are different deleted users. That hypothetical edge-case is not important to the *current* issue under discussion. ### Response:
SELECT p.Id AS "post_link", LastEditDate FROM Posts AS p WHERE NOT p.LastEditDate IS NULL AND p.LastEditorUserId IS NULL AND NOT p.OwnerUserId IS NULL ORDER BY p.LastEditDate 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, a line chart shows the trend of employee_id over hire_date . ### Response:
SELECT HIRE_DATE, EMPLOYEE_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: provide the number of patients whose primary disease is atrial septal defect\mitral valve replacement;repair atrial-septal defect/sda and age is less than 59? ### 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.age < "59"
### 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 employee_id and manager_id . ### Response:
SELECT EMPLOYEE_ID, MANAGER_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: What is the last name of each student who is not allergic to any type of food? Count them with a bar chart, sort total number in asc order. ### Response:
SELECT LName, COUNT(LName) FROM Student WHERE NOT StuID IN (SELECT T1.StuID FROM Has_Allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.AllergyType = "food") GROUP BY LName ORDER BY COUNT(LName)
### Instruction: Is ROMLING 993 scheduled for any class on Friday ? ### Response:
SELECT DISTINCT course_offering.friday 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.department = 'ROMLING' AND course.number = 993 AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: count the number of patients whose diagnoses short title is nutritional marasmus 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.short_title = "Nutritional marasmus" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: what are the top three most commonly prescribed drugs during this 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', '-0 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 3
### Instruction: among patients tested for blood gas, how many of them had received drug code enox80i? ### 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 = "ENOX80I" AND lab."CATEGORY" = "Blood Gas"
### Instruction: how many patients whose diagnoses short title is episodic mood disord nos 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 = "Episodic mood disord NOS" AND prescriptions.drug_type = "BASE"
### Instruction: what is the number of patients whose diagnoses short title is single lb in-hosp w cs 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.short_title = "Single lb in-hosp w cs" AND lab."CATEGORY" = "Chemistry"
### Instruction: Show the number of courses each instructor taught in a bar chart, and could you show by the y-axis in desc? ### Response:
SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE GROUP BY EMP_FNAME ORDER BY COUNT(EMP_FNAME) DESC
### Instruction: find how many patients had admission location as clinic referral/premature and primary disease as sigmoid diverticulitis, colovestical fistula/sda. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND demographic.diagnosis = "SIGMOID DIVERTICULITIS, COLOVESTICAL FISTULA/SDA"
### Instruction: how many patients are primarily diagnosed for coronary artery disease or coronary artery bypass graft with mvr maze and died in or before 2179.0? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT WITH MVR; ? MAZE" AND demographic.dod_year <= "2179.0"
### Instruction: Find the name of the person who has friends with age above 40 and under age 30? ### Response:
SELECT T1.name FROM person AS T1 JOIN personfriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM person WHERE age > 40) INTERSECT SELECT T1.name FROM person AS T1 JOIN personfriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM person WHERE age < 30)
### Instruction: A lista de usu rios que criaram ou responderam apenas _uma_ pergunta. ### Response:
SELECT Users.Id, COUNT(Posts.Id) AS Total, PostTypes.Name, 'StackOverflow' AS base FROM Users JOIN Posts ON Users.Id = Posts.OwnerUserId JOIN PostTypes ON Posts.PostTypeId = PostTypes.Id WHERE PostTypes.Id IN (1, 2) GROUP BY Users.Id, PostTypes.Name HAVING COUNT(Posts.Id) = 1
### Instruction: tell me the name of the specimen test patient 1862 received for the last time during their last hospital encounter? ### Response:
SELECT microbiologyevents.spec_type_desc FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1862 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) 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 trend about department_id over hire_date , sort by the x-axis in descending please. ### 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: let me know the number of patients on ih route of drug administration who have diagnoses icd9 code 81201. ### 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 = "81201" AND prescriptions.route = "IH"
### Instruction: What is the release date of part 80525py500512bx80525u500512bx80525u500512e? ### Response:
SELECT "Release date" FROM table_20777 WHERE "Part number(s)" = '80525PY500512BX80525U500512BX80525U500512E'
### Instruction: when was the last time of hospital admission in which patient 006-77873 was admitted through the emergency department in 2104? ### Response:
SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '006-77873' AND patient.hospitaladmitsource = 'emergency department' AND STRFTIME('%y', patient.hospitaladmittime) = '2104' ORDER BY patient.hospitaladmittime DESC LIMIT 1
### Instruction: tell me the number of married patients who have been diagnosed with hypertensive chronic kidney disease, unspecified, with chronic kidney disease stage i through stage iv, or unspecified. ### 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.short_title = "Hy kid NOS w cr kid I-IV"
### 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 scatter chart about the correlation between employee_id and manager_id . ### Response:
SELECT EMPLOYEE_ID, MANAGER_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: what is the number of patients prescribed sulfameth/trimethoprim ds who were admitted via physician referral/normal delivery? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND prescriptions.drug = "Sulfameth/Trimethoprim DS"