instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: A bar chart for finding the number of the first name of students who are living in the Smith Hall, and display from high to low by the x axis. ### Response:
SELECT Fname, COUNT(Fname) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' GROUP BY Fname ORDER BY Fname DESC
### Instruction: Which film is rented at a fee of 0.99 and has less than 3 in the inventory? List the film title and id. ### Response:
SELECT title, film_id FROM film WHERE rental_rate = 0.99 INTERSECT SELECT T1.title, T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id HAVING COUNT(*) < 3
### Instruction: Which Multi 1 has a Frequency of 2300mhz, and a Release date of q3 2008 and a Model number of turion x2 ultra zm-84? ### Response:
SELECT "Multi 1" FROM table_7400 WHERE "Frequency" = '2300mhz' AND "Release date" = 'q3 2008' AND "Model number" = 'turion x2 ultra zm-84'
### Instruction: For those employees who did not have any job in the past, a bar chart shows the distribution of hire_date and the average of employee_id bin hire_date by weekday, list Y-axis from low to high order please. ### Response:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(EMPLOYEE_ID)
### Instruction: For all employees who have the letters D or S in their first name, show me about the distribution of job_id and the sum of department_id , and group by attribute job_id in a bar chart, and list by the Y-axis in descending. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY SUM(DEPARTMENT_ID) DESC
### Instruction: Draw a bar chart for how many stores are headquarted in each city?, and I want to display by the x axis from low to high. ### Response:
SELECT Headquartered_City, COUNT(*) FROM store AS t1 JOIN store_district AS t2 ON t1.Store_ID = t2.Store_ID JOIN district AS t3 ON t2.District_ID = t3.District_ID GROUP BY t3.Headquartered_City ORDER BY Headquartered_City
### Instruction: what drug has patient 77177 been prescribed two or more times? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 77177) GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 >= 2
### Instruction: what was the number of patients receiving antibacterials - carbapenem until 2 years ago? ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'antibacterials - carbapenem' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-2 year'))
### Instruction: what is the number of patients whose diagnoses icd9 code is 87340 and lab test abnormal status is 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.icd9_code = "87340" AND lab.flag = "delta"
### Instruction: give me the number of patients whose drug code is alte1i and lab test fluid is ascites? ### 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 = "ALTE1I" AND lab.fluid = "Ascites"
### Instruction: what is the number of patients whose procedure icd9 code is 3799 and drug type is base? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "3799" AND prescriptions.drug_type = "BASE"
### Instruction: For those employees who did not have any job in the past, find hire_date and the sum of employee_id bin hire_date by time, and visualize them by a bar chart, and rank in asc by the sum employee id please. ### Response:
SELECT HIRE_DATE, SUM(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY SUM(EMPLOYEE_ID)
### Instruction: All questions with a *single* tag in last month. ### Response:
SELECT Id AS "post_link" FROM Posts WHERE PostTypeId = 1 AND DATEPART(m, CreationDate) = DATEPART(m, DATEADD(m, -1, GETDATE())) AND DATEPART(yyyy, CreationDate) = DATEPART(yyyy, DATEADD(m, -1, GETDATE())) AND Tags = CONCAT('<', '##Tag:string##', '>') ORDER BY CreationDate DESC
### Instruction: how many patients whose drug code is hepa10s and lab test fluid is ascites? ### 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 = "HEPA10S" AND lab.fluid = "Ascites"
### Instruction: how many of the patients with icd9 code 34830 had dialys? ### 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 = "34830" AND prescriptions.route = "DIALYS"
### 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 hire_date and the sum of salary bin hire_date by weekday. ### Response:
SELECT HIRE_DATE, SUM(SALARY) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### 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 email and manager_id , and list x-axis in ascending order please. ### 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: Is ASIAN 252 available during Spring 2010 ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'ASIAN' AND course.number = 252 AND semester.semester = 'Spring' AND semester.semester_id = course_offering.semester AND semester.year = 2010
### Instruction: how many patients are primary diagnosed for st elevated myocardial infarction or cardiac cath and have a lab test for blood? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "ST ELEVATED MYOCARDIAL INFARCTION\CARDIAC CATH" AND lab.fluid = "Blood"
### Instruction: out of total number of patients who had endoscopic insertion of stent (tube) into bile duct, calculate the number of those aged below 45 ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.age < "45" AND procedures.long_title = "Endoscopic insertion of stent (tube) into bile duct"
### Instruction: Show the number of engineers for different other details in a bar chart, and rank y-axis from low to high order please. ### Response:
SELECT other_details, COUNT(other_details) FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id = T2.engineer_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id GROUP BY other_details ORDER BY COUNT(other_details)
### Instruction: My answers without custom tag. List all answer posts to questions without Delphi tag. ### Response:
SELECT Answer.Id AS "post_link", Answer.Score AS "score", Question.Tags, Answer.CreationDate AS "creation_date" FROM Posts AS Question LEFT JOIN Posts AS Answer ON Question.Id = Answer.ParentId WHERE Answer.PostTypeId = 2 AND Answer.OwnerUserId = @MyUserID AND NOT Question.Tags LIKE @MyTagOfChoice ORDER BY Question.CreationDate
### Instruction: Show the ids and details of the investors who have at least two transactions with type code 'SALE' Plot them as bar chart, order total number in asc order. ### Response:
SELECT T1.Investor_details, T1.investor_id FROM Investors AS T1 JOIN Transactions AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = "SALE" ORDER BY T1.investor_id
### Instruction: Return the number of the completion date for all the tests that have 'Fail' result, and rank by the bar in asc. ### Response:
SELECT date_of_completion, COUNT(date_of_completion) FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Fail" GROUP BY date_of_completion ORDER BY date_of_completion
### Instruction: Provide me the number of patients taking base type drug prescriptions who have hip pressure ulcer. ### 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 = "Pressure ulcer, hip" AND prescriptions.drug_type = "BASE"
### Instruction: what was the last ward identification of patient 56348 in 2103? ### Response:
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 56348) AND NOT transfers.wardid IS NULL AND STRFTIME('%y', transfers.intime) = '2103' ORDER BY transfers.intime DESC LIMIT 1
### Instruction: count the number of patients whose diagnoses long title is perforation of intestine and lab test abnormal status is abnormal? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Perforation of intestine" AND lab.flag = "abnormal"
### Instruction: count the number of patients who had delta abnormal lab test status and other specified perinatal disorders of digestive system. ### 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 = "Perinat GI sys dis NEC" AND lab.flag = "delta"
### Instruction: According to Other requirements which courses in Special African Art should be taken ? ### 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 '%Special African Art%' OR course.description LIKE '%Special African Art%' OR course.name LIKE '%Special African Art%') AND program_course.category LIKE '%Other%'
### Instruction: Find the number of booking start date for the apartments that have more than two bedrooms for each weekday with a bar chart, display in descending by the Y-axis. ### Response:
SELECT booking_start_date, COUNT(booking_start_date) FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.bedroom_count > 2 ORDER BY COUNT(booking_start_date) DESC
### Instruction: Top Finland Java Answers writers. ### Response:
SELECT u.DisplayName, u.Reputation, COUNT(*) AS ClojureAnswers FROM Users AS u, Posts AS p, Posts AS pp WHERE u.Id IN (SELECT Id FROM Users WHERE Location LIKE ('%Finland')) AND p.OwnerUserId = u.Id AND pp.Id = p.ParentId AND pp.Tags LIKE ('%<clojure>%') GROUP BY u.DisplayName, u.Reputation ORDER BY ClojureAnswers DESC
### Instruction: What is the smallest year for a Main of Eintracht Frankfurt, Rhein of Waldhof Mannheim, Sarr of FK Pirmasens, and Hessen of Wormatia Worms? ### Response:
SELECT MIN("Year") FROM table_63901 WHERE "Main" = 'eintracht frankfurt' AND "Rhein" = 'waldhof mannheim' AND "Saar" = 'fk pirmasens' AND "Hessen" = 'wormatia worms'
### Instruction: how many patients had the drug code syringes and lab test fluid other body fluid? ### 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 = "SYRINGENS" AND lab.fluid = "Other Body Fluid"
### Instruction: what is the total number of patients diagnosed with icd9 code 45620 who had a blood 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.icd9_code = "45620" AND lab.fluid = "Blood"
### Instruction: First User to get a Bronze Tag-Based Badge. ### Response:
SELECT B.Name, B.UserId AS "user_link" FROM Badges AS B WHERE Class = 3 AND TagBased = 1 AND Id = (SELECT MIN(B2.Id) FROM Badges AS B2 WHERE B2.Name = B.Name AND B2.Class = 3 AND B2.TagBased = 1) GROUP BY B.Name, B.UserId ORDER BY B.Name
### Instruction: provide the number of patients whose diagnoses short title is anemia in chr kidney dis 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 = "Anemia in chr kidney dis" AND lab.fluid = "Urine"
### Instruction: give me the top four most common diagnoses since 1 year ago. ### Response:
SELECT t1.diagnosisname FROM (SELECT diagnosis.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnosis WHERE DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 4
### Instruction: WHAT IS THE TYPE OF LAND WITH A 2010 POPULATION GREATER THAN 2539, A RURAL AREA, AND A 2007 POPULATION OF 2572? ### Response:
SELECT geographic_character FROM table_name_69 WHERE population__2010_ > 2539 AND urban_rural = "rural" AND population__2007_ = 2572
### Instruction: For those employees who did not have any job in the past, show me about the distribution of job_id and the sum of department_id , and group by attribute job_id in a bar chart, and rank Y from high to low order. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY SUM(DEPARTMENT_ID) DESC
### Instruction: hydralazine, 0.9% sodium chloride or insulin had been prescribed to patient 27242? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27242) AND prescriptions.drug IN ('hydralazine', '0.9% sodium chloride', 'insulin')
### Instruction: Lowest question-score to comment-score ratios. ### Response:
SELECT Comments.Id AS "comment_link", Posts.Score AS "post_score", Comments.Score AS "comment_score", Comments.Score / Posts.Score AS "score_ratio" FROM Comments JOIN Posts ON Comments.PostId = Posts.Id WHERE Posts.Score != 0 AND Posts.PostTypeId = 1 ORDER BY 'score_ratio' LIMIT 100
### Instruction: what is the number of days elapsed since patient 65582's intensive care unit admission? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', icustays.intime)) FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 65582) AND icustays.outtime IS NULL
### Instruction: What are the latest papers by Nigam H. Shah and Srinivasan Iyer ? ### Response:
SELECT DISTINCT paper.year, writes.paperid FROM author, paper, writes WHERE author.authorname IN ('Nigam H. Shah', 'Srinivasan Iyer') AND writes.authorid = author.authorid AND writes.paperid = paper.paperid GROUP BY writes.paperid HAVING COUNT(DISTINCT writes.authorid) = 2 ORDER BY paper.year DESC
### Instruction: how many patients are with diagnosis icd9 code 70722 and drug route tp? ### 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 = "70722" AND prescriptions.route = "TP"
### Instruction: What is the highest percent supporting prohibition when the number opposing is less than 2,978 and the percent opposing is less than 31.2 while the number supporting is less than 9,461? ### Response:
SELECT MAX("Percent For") FROM table_51223 WHERE "Against Prohibition" < '2,978' AND "Percent Against" < '31.2' AND "For Prohibition" < '9,461'
### Instruction: Give me the number of patients diagnosed with hypotension of hemodialysis who had abnormal lab test status. ### 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 = "Hemododialysis hypotensn" AND lab.flag = "abnormal"
### Instruction: tell me the number of patients on base drug prescription who have procedure icd9 code 5771. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "5771" AND prescriptions.drug_type = "BASE"
### 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 salary , order by the bars from low to high. ### 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 PHONE_NUMBER
### 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, what is the relationship between salary and commission_pct ? ### Response:
SELECT SALARY, COMMISSION_PCT FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: Compare the total number of different job titles for all those jobs in department 80 using a bar chart, show y-axis in descending order. ### Response:
SELECT JOB_TITLE, COUNT(JOB_TITLE) FROM employees AS T1 JOIN jobs AS T2 ON T1.JOB_ID = T2.JOB_ID WHERE T1.DEPARTMENT_ID = 80 GROUP BY JOB_TITLE ORDER BY COUNT(JOB_TITLE) DESC
### Instruction: For those employees who was hired before 2002-06-21, visualize a bar chart about the distribution of job_id and the average of department_id , and group by attribute job_id, I want to rank in desc by the names please. ### Response:
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID DESC
### Instruction: what is the number of patients whose diagnoses long title is blood in stool 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.long_title = "Blood in stool" AND prescriptions.route = "REPLACE"
### Instruction: is there any record of microbiology test done for patient 32163 this year? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 32163) AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: how many patients whose diagnoses icd9 code is v1251 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 = "V1251" AND lab.fluid = "Other Body Fluid"
### Instruction: give me the number of patients whose ethnicity is hispanic/latino - puerto rican and drug type is main? ### 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.drug_type = "MAIN"
### Instruction: Find the number of booking start date for the apartments that have more than two bedrooms for each year with a bar chart, could you show in ascending by the total number please? ### Response:
SELECT booking_start_date, COUNT(booking_start_date) FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.bedroom_count > 2 ORDER BY COUNT(booking_start_date)
### Instruction: count the number of patients whose diagnoses long title is morbid obesity and lab test category is chemistry? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Morbid obesity" AND lab."CATEGORY" = "Chemistry"
### Instruction: provide the number of patients whose diagnosis short title is chronic pain nec 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.short_title = "Chronic pain NEC" AND prescriptions.drug_type = "MAIN"
### Instruction: give me the number of patients whose diagnosis short title is obstructive sleep apnea and drug route is pr. ### 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 = "Obstructive sleep apnea" AND prescriptions.route = "PR"
### Instruction: That stupid windows clock question. ### Response:
SELECT vt.Name, COUNT(pf.VoteTypeId) FROM PostFeedback AS pf INNER JOIN VoteTypes AS vt ON pf.VoteTypeId = vt.Id WHERE pf.PostId = 19051750 AND pf.IsAnonymous = 'true' AND vt.Name = '##UpDownMod:string?UpMod##' GROUP BY pf.VoteTypeId, vt.Name
### Instruction: how many patients whose discharge location is rehab/distinct part hosp were diagnosed with myalgia and myositis nos? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.discharge_location = "REHAB/DISTINCT PART HOSP" AND diagnoses.short_title = "Myalgia and myositis NOS"
### Instruction: What is the Right Ascension with a Diffuse Nebula Object Type has a 42 30 Declination and a NGC less than 6995? ### Response:
SELECT "Right ascension ( J2000 )" FROM table_11441 WHERE "NGC number" < '6995' AND "Object type" = 'diffuse nebula' AND "Declination ( J2000 )" = '°42′30″'
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find email and salary , and visualize them by a bar chart, and display by the Y-axis from low to high. ### Response:
SELECT EMAIL, 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 was the name of procedure, that patient 015-67291 was first received? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-67291')) ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: For those employees who did not have any job in the past, give me the comparison about the average of department_id over the job_id , and group by attribute job_id by a bar chart, could you order in ascending by the X-axis please? ### Response:
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: what is the number of patients whose gender is m and diagnoses long title is atherosclerosis of native arteries of the extremities with gangrene? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.gender = "M" AND diagnoses.long_title = "Atherosclerosis of native arteries of the extremities with gangrene"
### Instruction: how many times has remove skull tongs procedure been done until 2104? ### 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 = 'remove skull tongs') AND STRFTIME('%y', procedures_icd.charttime) <= '2104'
### 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 average of manager_id , and group by attribute job_id, and display Y-axis in asc order. ### Response:
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY AVG(MANAGER_ID)
### Instruction: how much is patient 006-168146 obligated to pay for the hospitalization during the last hospital encounter? ### Response:
SELECT SUM(cost.cost) FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-168146' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)
### Instruction: provide the number of patients with diagnoses icd9 code 78057 who had pleural fluid 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.icd9_code = "78057" AND lab.fluid = "Pleural"
### Instruction: Recent comments on answers to my questions. ### Response:
SELECT c.Id AS "comment_link", c.UserId AS "user_link", c.CreationDate, a.Id AS "post_link", c.Text FROM (Posts AS q JOIN Posts AS a ON q.Id = a.ParentId) JOIN Comments AS c ON c.PostId = a.Id WHERE q.OwnerUserId = '##userid##' ORDER BY c.CreationDate DESC LIMIT 100
### 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 salary , order y-axis from high to low order. ### Response:
SELECT JOB_ID, SALARY FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SALARY DESC
### Instruction: what is minimum age of patients whose marital status is divorced and primary disease is aortic insufficiency\re-do sternotomy; aortic valve replacement ? ### Response:
SELECT MIN(demographic.age) FROM demographic WHERE demographic.marital_status = "DIVORCED" AND demographic.diagnosis = "AORTIC INSUFFICIENCY\RE-DO STERNOTOMY; AORTIC VALVE REPLACEMENT "
### Instruction: For those employees who did not have any job in the past, return a bar chart about the distribution of job_id and the sum of employee_id , and group by attribute job_id, order by the total number in asc. ### 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: Who is the 'CTO' of club 'Hopkins Student Enterprises'? Show the first name and last name. ### Response:
SELECT t3.fname, t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Hopkins Student Enterprises" AND t2.position = "CTO"
### Instruction: How many % of questions are accepted / answered?. ### Response:
SELECT SUM(CASE WHEN NOT AcceptedAnswerId IS NULL THEN 1 ELSE 0 END) AS Accepted, SUM(CASE WHEN AcceptedAnswerId IS NULL THEN 1 ELSE 0 END) AS NotAccepted, SUM(CASE WHEN NOT ClosedDate IS NULL THEN 1 ELSE 0 END) AS Closed, SUM(CASE WHEN AnswerCount = 0 THEN 1 ELSE 0 END) AS Unanswered, COUNT(*) AS Total FROM Posts
### Instruction: For all employees who have the letters D or S in their first name, visualize a bar chart about the distribution of job_id and the average of manager_id , and group by attribute job_id, show by the total number from low to high please. ### Response:
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY AVG(MANAGER_ID)
### Instruction: How many values for small power demand occur when medium power demand is 11.07? ### Response:
SELECT COUNT("Small power Power demand: 40 kW; Consumption 10,000 kWh, load factor: 35%.") FROM table_23948 WHERE "Medium power Power demand: 1,000 kW; Consumption: 400,000 kWh, load factor: 56 %." = '11.07'
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about salary over the last_name by a bar chart, list bar in ascending order please. ### Response:
SELECT LAST_NAME, SALARY 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 patient 009-7776 had any allergies in the current hospital visit? ### 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 = '009-7776' AND patient.hospitaldischargetime IS NULL))
### Instruction: has patient 032-9230 had a lab test of troponin - i? ### Response:
SELECT COUNT(*) > 0 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '032-9230')) AND lab.labname = 'troponin - i'
### Instruction: what is the number of patients whose ethnicity is american indian/alaska native and procedure short title is chordae tendineae ops? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND procedures.short_title = "Chordae tendineae ops"
### Instruction: Next semester , are there a lot of lecture sections being offered for NRE 557 ? ### Response:
SELECT COUNT(*) FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'NRE' AND course.number = 557 AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: what was the first time patient 018-115975 has had the hospital discharge in this year? ### Response:
SELECT patient.hospitaldischargetime FROM patient WHERE patient.uniquepid = '018-115975' AND DATETIME(patient.hospitaldischargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY patient.hospitaldischargetime LIMIT 1
### Instruction: What is Result, when Venue is Sydney Cricket Ground, and when Date is 23,24,26,27,28,29 Feb, 1 Mar 1912? ### Response:
SELECT "Result" FROM table_42767 WHERE "Venue" = 'sydney cricket ground' AND "Date" = '23,24,26,27,28,29 feb, 1 mar 1912'
### Instruction: what is the number of patients whose admission location is phys referral/normal deli and diagnoses icd9 code is e9530? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND diagnoses.icd9_code = "E9530"
### Instruction: How many patients were diagnosed with hemorrhagic complications and had 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 = "Hemorrhage complic proc" AND lab."CATEGORY" = "Chemistry"
### Instruction: get me the number of patients who are diagnosed with unspecified acute uri and are taking drug via po 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 = "Acute uri NOS" AND prescriptions.route = "PO"
### Instruction: Give me the list of patients with urgent hospital admission who are on the prescription drug cetylpyridinium chl (cepacol). ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_type = "URGENT" AND prescriptions.drug = "Cetylpyridinium Chl (Cepacol)"
### Instruction: For those employees who was hired before 2002-06-21, give me the comparison about the sum of manager_id over the hire_date bin hire_date by time by a bar chart, I want to show from low to high by the y axis. ### Response:
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY SUM(MANAGER_ID)
### Instruction: Give me a bar chart showing the number of buildings managed by 'Kyle' and group by apartment type codes, rank y-axis in desc order please. ### Response:
SELECT apt_type_code, COUNT(apt_type_code) FROM Apartment_Buildings AS T1 JOIN Apartments AS T2 ON T1.building_id = T2.building_id WHERE T1.building_manager = "Kyle" GROUP BY apt_type_code ORDER BY COUNT(apt_type_code) DESC
### Instruction: Which 8.23 g (127 gr) is the highest one that has a Bullet weight gram (grain) of 8x64mm s, and a Case capacity (%) smaller than 110.3? ### Response:
SELECT MAX("8.23 g (127 gr)") FROM table_5326 WHERE "Bullet weight gram (grain)" = '8x64mm s' AND "Case capacity (%)" < '110.3'
### Instruction: What is the first name of students enrolled in class ACCT-211 and got grade C? ### Response:
SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211' AND T2.enroll_grade = 'C'
### Instruction: what number of patients with hematology as lab test category had complete atroiventricular block? ### 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 = "Atrioventricular block, complete" AND lab."CATEGORY" = "Hematology"
### Instruction: give the number of patients whose diagnosis short title is nephritis nos 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 = "Nephritis NOS" AND lab."CATEGORY" = "Chemistry"
### Instruction: count the number of patients whose diagnoses short title is benign neo skin face nec and lab test abnormal status is 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 = "Benign neo skin face NEC" AND lab.flag = "delta"
### Instruction: what was patient 13536's last ward identification on their first hospital encounter? ### Response:
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13536 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND NOT transfers.wardid IS NULL ORDER BY transfers.intime DESC LIMIT 1
### Instruction: provide the number of patients categorized under hematology lab test who were diagnosed with hip pressure ulcer. ### 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 = "Pressure ulcer, hip" AND lab."CATEGORY" = "Hematology"
### Instruction: when was the first time that patient 31854 was prescribed medication via an pb route in their current hospital encounter? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31854 AND admissions.dischtime IS NULL) AND prescriptions.route = 'pb' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: For all employees who have the letters D or S in their first name, draw a bar chart about the distribution of hire_date and the average of employee_id bin hire_date by time, could you order in ascending by the y-axis? ### Response:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(EMPLOYEE_ID)