instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: What year has a Schwante smaller than 2.043, an Eichst dt smaller than 848, and a B renklau smaller than 1.262? ### Response:
SELECT COUNT("Year") FROM table_77501 WHERE "Schwante" < '2.043' AND "Eichst\u00e4dt" < '848' AND "B\u00e4renklau" < '1.262'
### Instruction: how many times had patient 006-83902 visited intensive care unit until 2103? ### Response:
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-83902') AND STRFTIME('%y', patient.unitadmittime) <= '2103'
### Instruction: What is the long-term capital gain rate when the long-term gain on commercial buildings is 25% and long term gain on collectibles is 28% while short-term capital gain rate is 33%? ### Response:
SELECT "Long-term capital gain rate" FROM table_55784 WHERE "Long-term gain on commercial buildings*" = '25%' AND "Long-term gain on collectibles" = '28%' AND "Short-term capital gain rate" = '33%'
### Instruction: what is patient 45612's first careunit since 5 years ago? ### Response:
SELECT transfers.careunit FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 45612) AND NOT transfers.careunit IS NULL AND DATETIME(transfers.intime) >= DATETIME(CURRENT_TIME(), '-5 year') ORDER BY transfers.intime LIMIT 1
### Instruction: What is the average cash on hand of a candidate with receipts w/o loans of 19,951,290 and less than 17,556,672 spent? ### Response:
SELECT AVG("Cash On Hand") FROM table_10363 WHERE "Receipts w/o Loans" = '19,951,290' AND "Money Spent" < '17,556,672'
### Instruction: count the number of patients whose diagnoses long title is other shock without mention of trauma and drug route is sc? ### 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 shock without mention of trauma" AND prescriptions.route = "SC"
### Instruction: renal disease ( serum creatinine > 1.2 mg / dl ) or serum potassium abnormality ( < 3.4 or > 5.5 mmol / l ) ### Response:
SELECT * FROM table_dev_55 WHERE renal_disease = 1 OR serum_creatinine > 1.2 OR serum_potassium_abnormality < 3.4 OR serum_potassium_abnormality > 5.5
### Instruction: give me the number of patients whose diagnoses icd9 code is 431 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 = "431" AND lab."CATEGORY" = "Chemistry"
### Instruction: what ground transportation is available from LGA airport into NEW YORK ### Response:
SELECT DISTINCT transport_type FROM ground_service WHERE (airport_code IN (SELECT AIRPORTalias0.airport_code FROM airport AS AIRPORTalias0 WHERE AIRPORTalias0.airport_code = 'LGA') AND city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'NEW YORK'))
### Instruction: provide the number of patients whose diagnoses short title is late effect injury nos and drug route is po/ng? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Late effect injury NOS" AND prescriptions.route = "PO/NG"
### Instruction: For those employees who was hired before 2002-06-21, find job_id and the sum of employee_id , and group by attribute job_id, and visualize them by a bar chart, could you order x-axis in desc order? ### Response:
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID DESC
### Instruction: Show the number of documents in each day for all documents on project with details 'Graph Database project' and bin document date by year interval and group by document name with a group line chart, and order by the Document_Date in ascending. ### Response:
SELECT Document_Date, COUNT(Document_Date) FROM Documents AS T1 JOIN Projects AS T2 ON T1.Project_ID = T2.Project_ID WHERE T2.Project_Details = 'Graph Database project' GROUP BY Document_Name ORDER BY Document_Date
### Instruction: give me the number of patients whose diagnoses is noninf gastroenterit 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 = "Noninf gastroenterit NEC" AND lab.fluid = "Pleural"
### Instruction: Top N Users in Country. from http://data.stackexchange.com/stackoverflow/query/148176/top-users-by-country ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation, Location FROM Users WHERE LOWER(Location) LIKE LOWER('%##FullCountryName##%') OR (Location) LIKE UPPER('%##ShortCountryName##') ORDER BY Reputation DESC LIMIT 100
### Instruction: What are the descriptions of the service types with product price above 100, and count them by a bar chart, I want to sort by the bars in asc. ### Response:
SELECT Service_Type_Description, COUNT(Service_Type_Description) FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code WHERE T2.Product_Price > 100 GROUP BY Service_Type_Description ORDER BY Service_Type_Description
### Instruction: count the number of patients whose discharge location is short term hospital and procedure long title is combined right and left heart cardiac catheterization? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "SHORT TERM HOSPITAL" AND procedures.long_title = "Combined right and left heart cardiac catheterization"
### Instruction: Next semester , is ORALBIOL 853 course being offered ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'ORALBIOL' AND course.number = 853 AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: What is the sum of Rank, when Province is G l n, when Date of Official Foundation of Municipality is after 1922, and when 2006 is greater than 557366? ### Response:
SELECT SUM("Rank") FROM table_44170 WHERE "Province" = 'gīlān' AND "Date of Official Foundation of Municipality" > '1922' AND "2006" > '557366'
### Instruction: what number of married patients had their lab test chart time as 2165-06-23 22:30:00? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.marital_status = "MARRIED" AND lab.charttime = "2165-06-23 22:30:00"
### Instruction: give me the number of patients whose diagnoses icd9 code is v5416 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.icd9_code = "V5416" AND lab.fluid = "Pleural"
### Instruction: How many posts have I edited?. ### Response:
SELECT Posts.LastEditorUserId AS "userid", COUNT(DISTINCT Posts.Id) AS "edited_posts" FROM Posts WHERE Posts.LastEditorUserId = '##UserId##' AND Posts.PostTypeId = 1 AND Posts.OwnerUserId != '##UserId##' AND Posts.ClosedDate IS NULL AND Posts.CommunityOwnedDate IS NULL GROUP BY Posts.LastEditorUserId
### Instruction: what is the number of patients whose diagnoses short title is chronic kidney dis nos and drug route is sc? ### 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 kidney dis NOS" AND prescriptions.route = "SC"
### Instruction: Who 's teaching computing infrastructure courses ? ### 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 area ON course_offering.course_id = area.course_id WHERE area.area LIKE '%computing infrastructure%'
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find job_id and salary , and visualize them by a bar chart, rank by the X-axis in asc. ### 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 JOB_ID
### Instruction: does heparin crrt have been prescribed to patient 15209 in 2105? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15209) AND prescriptions.drug = 'heparin crrt' AND STRFTIME('%y', prescriptions.startdate) = '2105'
### Instruction: What is the highest week 9 that had a week 6 of 7, a week 10 of greater than 2, a week 7 of 5, and a week 11 less than 2? ### Response:
SELECT MAX("Wk 9") FROM table_38961 WHERE "Wk 6" = '7' AND "Wk 10" > '2' AND "Wk 7" = '5' AND "Wk 11" < '2'
### Instruction: does any image frame have the same height as the nokia lumia 720 ? ### Response:
SELECT (SELECT COUNT(*) FROM table_203_356 WHERE "type" <> '1/3.6" (nokia lumia 720)' AND "height (mm)" = (SELECT "height (mm)" FROM table_203_356 WHERE "type" = '1/3.6" (nokia lumia 720)')) > 0
### Instruction: count the number of patients whose diagnoses icd9 code is 34830 and lab test fluid is ascites? ### 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 = "34830" AND lab.fluid = "Ascites"
### Instruction: How many patients of hispanic,latino, or puerto rican ethnicity were given the drug albuterol? ### 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 = "Albuterol"
### Instruction: Show the ids and names of festivals that have at least two nominations for artworks by a bar chart, rank in descending by the y axis. ### 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 T1.Festival_ID DESC
### Instruction: How many patients of white russian ethnicity had a procedure for dorsal and dorsolumbar fusion of the posterior column posterior technique? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.ethnicity = "WHITE - RUSSIAN" AND procedures.long_title = "Dorsal and dorsolumbar fusion of the posterior column, posterior technique"
### Instruction: What is the average attendnace for seasons before 1986, a margin of 6, and a Score of 13.16 (94) 13.10 (88)? ### Response:
SELECT AVG("Attendance") FROM table_53779 WHERE "Season" < '1986' AND "Margin" = '6' AND "Score" = '13.16 (94) – 13.10 (88)'
### Instruction: how many patients whose drug code is metr500pm had lab test fluid 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 = "METR500PM" AND lab.fluid = "Ascites"
### Instruction: periph t cell lym abdom what does it stand for? ### Response:
SELECT d_icd_diagnoses.long_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'periph t cell lym abdom' UNION SELECT d_icd_procedures.long_title FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'periph t cell lym abdom'
### Instruction: what is the number of patients whose procedure icd9 code is 8619 and drug route is left eye? ### 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 = "8619" AND prescriptions.route = "LEFT EYE"
### Instruction: when is the last time patient 87232 has been prescribed medicine since 2 months ago? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 87232) AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-2 month') ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: For those employees who was hired before 2002-06-21, visualize a bar chart about the distribution of hire_date and the average of department_id bin hire_date by time, could you sort by the the average of department id in asc? ### Response:
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(DEPARTMENT_ID)
### Instruction: For those employees who was hired before 2002-06-21, draw a bar chart about the distribution of job_id and the sum of department_id , and group by attribute job_id, and display y-axis from low to high order. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY SUM(DEPARTMENT_ID)
### Instruction: what is the number of patients born before 2035 who were diagnosed with 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: WHAT ARE THE RACES WHEN FLAPS ARE ZERO, PODIUMS ARE LARGER THAN 0, SEASON IS 2008, AND POLE SMALLER THAN 1? ### Response:
SELECT SUM("Races") FROM table_51171 WHERE "FLaps" = '0' AND "Podiums" > '0' AND "Season" = '2008' AND "Pole" < '1'
### Instruction: report the number of american indian/alaska native ethnic background patients who have diagnoses icd9 code 51881. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND diagnoses.icd9_code = "51881"
### Instruction: Changes in technologies in UK. ### Response:
SELECT DATE(CreationDate) AS "date", COUNT(*) FROM Posts WHERE PostTypeId = 1 AND (Tags LIKE '%<java>%' AND Tags LIKE '%<.net>%' AND Tags LIKE '%<node.js>%' AND Tags LIKE '%<php>%' AND Tags LIKE '%<python>%' AND Tags LIKE '%<ruby>%' AND Tags LIKE '%<wordpress>%') GROUP BY DATE(CreationDate) ORDER BY DATE(CreationDate)
### Instruction: show me the aircraft that CANADIAN AIRLINES uses ### Response:
SELECT DISTINCT aircraft.basic_type FROM aircraft, airline, equipment_sequence, flight WHERE airline.airline_name LIKE 'CANADIAN AIRLINES' AND equipment_sequence.aircraft_code = aircraft.aircraft_code AND flight.aircraft_code_sequence = equipment_sequence.aircraft_code_sequence AND flight.airline_code = airline.airline_code
### Instruction: count the number of patients whose diagnosis short title is complete kidney transplant 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 = "Compl kidney transplant" AND prescriptions.route = "REPLACE"
### Instruction: Calculate the number of patients less than 68 years who have primary disease atrial fibrillation/thoracoscopic maze and had a bilateral/sda procedure. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "ATRIAL FIBRILLATION\THORACOSCOPIC MAZE PROCEDURE BILATERAL/SDA" AND demographic.age < "68"
### Instruction: Is 583 offered in the next 2 years ? ### Response:
SELECT DISTINCT semester.semester, semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 583 AND semester.semester_id = course_offering.semester AND semester.year IN (2016, 2017)
### Instruction: how many patients are diagnosed with icd9 code 43401 and tested in lab for joint 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 = "43401" AND lab.fluid = "Joint Fluid"
### Instruction: Show the church names for the weddings of all people older than 30. ### Response:
SELECT T4.name FROM wedding AS T1 JOIN people AS T2 ON T1.male_id = T2.people_id JOIN people AS T3 ON T1.female_id = T3.people_id JOIN church AS T4 ON T4.church_id = T1.church_id WHERE T2.age > 30 OR T3.age > 30
### Instruction: provide the number of patients whose ethnicity is black/haitian and diagnoses long title is personal history of antineoplastic chemotherapy? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "BLACK/HAITIAN" AND diagnoses.long_title = "Personal history of antineoplastic chemotherapy"
### Instruction: Top SO users in Turkey. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS Rank, Reputation, CreationDate, DisplayName, LastAccessDate, WebsiteUrl, Location, AboutMe FROM Users WHERE (LOWER(Location) LIKE '%turke%' OR LOWER(Location) LIKE '%t rki%' OR UPPER(Location) LIKE '%Turke%' OR UPPER(Location) LIKE '%T rki%') ORDER BY Reputation DESC LIMIT 100
### Instruction: how many 50 ml flex cont : magnesium sulfate 4% ij soln prescriptions have been written during the previous year? ### Response:
SELECT COUNT(*) FROM medication WHERE medication.drugname = '50 ml flex cont : magnesium sulfate 4% ij soln' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
### Instruction: what is the last ward identifier of patient 29540 until 2104? ### Response:
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 29540) AND NOT transfers.wardid IS NULL AND STRFTIME('%y', transfers.intime) <= '2104' ORDER BY transfers.intime DESC LIMIT 1
### Instruction: For those employees who did not have any job in the past, show me about the distribution of job_id and the average of employee_id , and group by attribute job_id in a bar chart, and order from low to high by the names 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 JOB_ID
### Instruction: what is the average age for each dorm and what are the names of each dorm?, and show by the Y from high to low. ### Response:
SELECT dorm_name, AVG(T1.Age) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name ORDER BY AVG(T1.Age) DESC
### Instruction: give me the number of patients whose diagnoses short title is other pulmonary insuff 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 = "Other pulmonary insuff" AND prescriptions.route = "PR"
### Instruction: What are the names and sum of checking and savings balances for accounts with savings balances higher than the average savings balance? ### Response:
SELECT T1.name, T2.balance + T3.balance FROM accounts AS T1 JOIN checking AS T2 ON T1.custid = T2.custid JOIN savings AS T3 ON T1.custid = T3.custid WHERE T3.balance > (SELECT AVG(balance) FROM savings)
### Instruction: For those employees who was hired before 2002-06-21, show me about the distribution of hire_date and the average of manager_id bin hire_date by time in a bar chart, and sort by the total number in desc please. ### Response:
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(MANAGER_ID) DESC
### Instruction: how many patients used the drug code lido5t and tested with joint fluid in lab? ### 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 = "LIDO5T" AND lab.fluid = "Joint Fluid"
### Instruction: When Alberto Contador Kanstantsin Sivtsov was the general classification and Alessandro Petacchi was the points classification at the same time while Mark Cavendish is the winner, who was the mountain classification? ### Response:
SELECT mountains_classification FROM table_28538368_2 WHERE general_classification = "Alberto Contador Kanstantsin Sivtsov" AND points_classification = "Alessandro Petacchi" AND winner = "Mark Cavendish"
### Instruction: what did patient 027-178495 receive for his or her first procedure? ### 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 = '027-178495')) ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: For those records from the products and each product's manufacturer, a bar chart shows the distribution of headquarter and the average of code , and group by attribute headquarter, and I want to rank from high to low by the Headquarter. ### Response:
SELECT T2.Headquarter, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Headquarter ORDER BY T2.Headquarter DESC
### Instruction: provide the number of patients whose diagnoses icd9 code is 5070 and lab test fluid is joint 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 = "5070" AND lab.fluid = "Joint Fluid"
### Instruction: For all employees who have the letters D or S in their first name, return a bar chart about the distribution of job_id and the sum of manager_id , and group by attribute job_id, could you rank total number of manager id in ascending order please? ### Response:
SELECT JOB_ID, SUM(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY SUM(MANAGER_ID)
### Instruction: For those employees who was hired before 2002-06-21, draw a bar chart about the distribution of job_id and the average of employee_id , and group by attribute job_id, display in desc by the x-axis please. ### Response:
SELECT JOB_ID, AVG(EMPLOYEE_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 short title is hyperpotassemia 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 = "Hyperpotassemia" AND prescriptions.drug_type = "MAIN"
### Instruction: For those employees who did not have any job in the past, give me the comparison about the amount of job_id over the job_id , and group by attribute job_id by a bar chart, and list how many job id from low to high order. ### Response:
SELECT JOB_ID, COUNT(JOB_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY COUNT(JOB_ID)
### Instruction: provide the number of patients whose diagnoses short title is acute kidney failure nos and drug route is nu? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Acute kidney failure NOS" AND prescriptions.route = "NU"
### Instruction: when was the last time for patient 49036 procedure when they visited the hospital last time? ### Response:
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 49036 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY procedures_icd.charttime DESC LIMIT 1
### Instruction: let me know the number of patients admitted before 2115 who had injection or infusion of oxazolidinone class of antibiotics. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2115" AND procedures.long_title = "Injection or infusion of oxazolidinone class of antibiotics"
### Instruction: Can I take BUDDHST 501 next semester ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'BUDDHST' AND course.number = 501 AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: how many patients are diagnosed with icd9 code 78909 and have pr 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.icd9_code = "78909" AND prescriptions.route = "PR"
### Instruction: was patient 52898 prescribed levofloxacin in 2105? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 52898) AND prescriptions.drug = 'levofloxacin' AND STRFTIME('%y', prescriptions.startdate) = '2105'
### Instruction: provide the number of patients whose procedure icd9 code is 4576 and drug route is iv bolus ### 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 = "4576" AND prescriptions.route = "IV BOLUS"
### Instruction: What volume number has the ISBN of 978-1-59582-712-8 (hc) 978-1-59582-713-5 (tpb)? ### Response:
SELECT volume FROM table_name_38 WHERE isbn = "978-1-59582-712-8 (hc) 978-1-59582-713-5 (tpb)"
### Instruction: how many times has patient 035-2205 visited the intensive care unit since 2104? ### Response:
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '035-2205') AND STRFTIME('%y', patient.unitadmittime) >= '2104'
### Instruction: how many patients with american indian/alaska native ethnicity have undergone the procedure closed bx skin/subq tiss? ### 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 = "Closed bx skin/subq tiss"
### Instruction: provide the number of patients whose diagnosis icd9 code is 4142 and lab test fluid is joint 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 = "4142" AND lab.fluid = "Joint Fluid"
### Instruction: For all employees who have the letters D or S in their first name, find job_id and the sum of employee_id , and group by attribute job_id, and visualize them by a bar chart, and show from high to low by the x-axis please. ### Response:
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY JOB_ID DESC
### Instruction: find the number of patients admitted in emergency whose drug code is glyc 1r. ### 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 = "80624" AND prescriptions.route = "INHALATION"
### Instruction: A bar chart for finding the number of the the date of enrollment of the 'Spanish' course, and sort Y-axis in asc order please. ### Response:
SELECT date_of_enrolment, COUNT(date_of_enrolment) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "Spanish" ORDER BY COUNT(date_of_enrolment)
### Instruction: count the number of patients whose drug code is amid200 and lab test fluid is blood? ### 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 = "AMID200" AND lab.fluid = "Blood"
### Instruction: provide the number of patients whose death status is 0 and procedure long title is insertion of non-drug-eluting coronary artery stent(s)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.expire_flag = "0" AND procedures.long_title = "Insertion of non-drug-eluting coronary artery stent(s)"
### Instruction: provide the number of patients whose diagnosis icd9 code is v1272 and lab test fluid is ascites. ### 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 = "V1272" AND lab.fluid = "Ascites"
### Instruction: Number of questions closed by close vote count.. Sceptics questions closed, by number of close votes. Useful to identify moderator-closed questions. ### Response:
SELECT 'close_votes', COUNT(*) FROM (SELECT COUNT(*) AS "close_votes" FROM Posts INNER JOIN Votes ON Posts.Id = Votes.PostId WHERE Votes.VoteTypeId = 6 AND NOT Posts.ClosedDate IS NULL GROUP BY Posts.Id) AS X GROUP BY 'close_votes'
### Instruction: return me the number of papers by ' H. V. Jagadish ' on VLDB conference after 2000 . ### Response:
SELECT COUNT(DISTINCT (publication.title)) FROM author, conference, publication, writes WHERE author.name = 'H. V. Jagadish' AND conference.name = 'VLDB' AND publication.cid = conference.cid AND publication.year > 2000 AND writes.aid = author.aid AND writes.pid = publication.pid
### Instruction: how many patients with residual foreign body in soft tissue had a lab test for blood gas? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Residual foreign body in soft tissue" AND lab."CATEGORY" = "Blood Gas"
### Instruction: What is the total number in the 1920s that has 0 in the 1960s, and less than 4 in the 2000s, and more than 3 in the 1930s? ### Response:
SELECT COUNT("1920s") FROM table_7584 WHERE "1960s" = '0' AND "2000s to date" < '4' AND "1930s" > '3'
### Instruction: give me the number of patients whose admission year is less than 2155 and diagnoses long title is other specified gastritis, with hemorrhage? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2155" AND diagnoses.long_title = "Other specified gastritis, with hemorrhage"
### Instruction: among patients diagnosed with critical illness myopthy, how many of them received drug via id 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 = "Critical illness myopthy" AND prescriptions.route = "ID"
### Instruction: Get me the number of patients with a delta lab test status who have a primary disease called st elevated myocardial infarction/cardiac cath. ### 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.flag = "delta"
### Instruction: how many of the patients with urin tract infection nos received additive therapy? ### 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 = "Urin tract infection NOS" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: how many patients whose diagnoses icd9 code is 56212 and drug route is ed? ### 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 = "56212" AND prescriptions.route = "ED"
### Instruction: Last 3 months unanswered questions. ### Response:
SELECT * FROM Posts INNER JOIN Users ON Users.Id = OwnerUserId WHERE Posts.PostTypeId = 1 AND Posts.CreationDate BETWEEN DATEADD(MONTH, -3, CURRENT_TIMESTAMP()) AND CURRENT_TIMESTAMP() AND AcceptedAnswerId IS NULL AND AnswerCount = 0 AND Score > -1 AND CommentCount = 0 AND Users.Reputation > 100
### Instruction: What is the highest 2007 value with a 1985 value greater than 52, a 1987 value greater than 130, and a 1990 less than 1990? ### Response:
SELECT MAX("2007") FROM table_40320 WHERE "1985" > '52' AND "1987" > '130' AND "1990" < '1990'
### Instruction: Questions, answers, comments, views for a list of tags. ### Response:
SELECT TagName, COUNT(PostId) AS Questions, SUM(AnswerCount) AS Answers, SUM(CommentCount) AS Comments, SUM(ViewCount) AS Views FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.Id = PostTags.PostId WHERE Tags.TagName IN ('##Tag##') AND Posts.PostTypeId = 1 GROUP BY TagName
### Instruction: when was the last time that patient 32163 received a procedure in the last hospital visit? ### Response:
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 32163 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY procedures_icd.charttime DESC LIMIT 1
### Instruction: Calculate the average age of emergency type hospital admission patients who have aortic insufficiency re-do sternotomy aortic valve replacement as their primary disease. ### Response:
SELECT AVG(demographic.age) FROM demographic WHERE demographic.admission_type = "EMERGENCY" AND demographic.diagnosis = "AORTIC INSUFFICIENCY\RE-DO STERNOTOMY; AORTIC VALVE REPLACEMENT "
### Instruction: For those employees who was hired before 2002-06-21, find hire_date and the amount of hire_date bin hire_date by time, and visualize them by a bar chart, sort by the how many hire date in descending please. ### Response:
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY COUNT(HIRE_DATE) DESC
### Instruction: provide the number of patients whose procedure long title is other partial resection of small intestine and lab test fluid is pleural? ### 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 = "Other partial resection of small intestine" AND lab.fluid = "Pleural"
### Instruction: What is the number of Jianshu when the total is more than 19.16, for Nguyen Huy Thanh ( vie ), and Qiangshu is more than 9.66? ### Response:
SELECT COUNT("Jianshu") FROM table_12362 WHERE "Total" > '19.16' AND "Athlete" = 'nguyen huy thanh ( vie )' AND "Qiangshu" > '9.66'