instruction
stringlengths
57
490
output
stringlengths
69
1.29k
### 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 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: 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)
### Instruction: Which channels broadcast both in the morning and at night? Give me the channel names. ### Response:
SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Morning' INTERSECT SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Night'
### Instruction: what is the declination (j2000) that has a constellation of hydra and a right ascension (j2000) of 10h46m44.9s? ### Response:
SELECT "Declination ( J2000 )" FROM table_55074 WHERE "Constellation" = 'hydra' AND "Right ascension ( J2000 )" = '10h46m44.9s'
### Instruction: provide the number of patients with a diagnoses of personal history of other malignant neoplasm of rectum, rectosigmoid junction and anus and are still alive. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.expire_flag = "0" AND diagnoses.short_title = "Hx-rectal & anal malign"
### Instruction: For those employees who did not have any job in the past, a bar chart shows the distribution of hire_date and the sum of department_id bin hire_date by weekday, and I want to list y axis from high to low order please. ### Response:
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY SUM(DEPARTMENT_ID) DESC
### Instruction: For those employees who was hired before 2002-06-21, a bar chart shows the distribution of job_id and the average of department_id , and group by attribute job_id, I want to sort in asc by the X-axis. ### Response:
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: How many students taking a course who received an A or C? Group by students' last name with a bar chart. ### Response:
SELECT STU_LNAME, COUNT(STU_LNAME) FROM STUDENT AS T1 JOIN ENROLL AS T2 ON T1.STU_NUM = T2.STU_NUM WHERE T2.ENROLL_GRADE = 'C' OR T2.ENROLL_GRADE = 'A' GROUP BY STU_LNAME
### Instruction: In which season and which stadium did any player have an injury of 'Foot injury' or 'Knee problem'? ### Response:
SELECT T1.season, T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.id JOIN injury_accident AS T3 ON T1.id = T3.game_id WHERE T3.injury = 'Foot injury' OR T3.injury = 'Knee problem'
### Instruction: provide the number of patients whose admission type is emergency and diagnoses is other pulmonary insufficiency, not elsewhere classfied. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND diagnoses.long_title = "Other pulmonary insufficiency, not elsewhere classified"
### Instruction: Which players won awards in both 1960 and 1961? Return their first names and last names. ### Response:
SELECT T1.name_first, T1.name_last FROM player AS T1 JOIN player_award AS T2 WHERE T2.year = 1960 INTERSECT SELECT T1.name_first, T1.name_last FROM player AS T1 JOIN player_award AS T2 WHERE T2.year = 1961
### Instruction: did the hall of fame player awarded the year after tony coton earn more goals than he did ? ### Response:
SELECT (SELECT "goals" FROM table_204_340 WHERE "year inducted" = (SELECT "year inducted" FROM table_204_340 WHERE "name" = 'tony coton') + 1) > (SELECT "goals" FROM table_204_340 WHERE "name" = 'tony coton')
### Instruction: How many states that have some college students playing in the mid position but not in the goalie position. ### Response:
SELECT COUNT(*) FROM (SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie')
### Instruction: What is the smallest amount of freight carried on the road that closed on March 31 and reached super B capacity on February 17 after 2011? ### Response:
SELECT MIN("Freight Carried s Tonne") FROM table_80057 WHERE "Road Closed" = 'march 31' AND "Super B Capacity Reached [ citation needed ]" = 'february 17' AND "Year" > '2011'
### Instruction: provide the number of patients whose ethnicity is black/cape verdean and drug code is docu100? ### 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 = "DOCU100"
### Instruction: Out of total number of patients admitted before the year 2150, how many of them were treated with dabigatran etexilate? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admityear < "2150" AND prescriptions.drug = "Dabigatran Etexilate"
### Instruction: Find the dates of assessment notes for students with first name 'Fanny', and count them by a bar chart, and I want to display by the y axis from low to high. ### Response:
SELECT date_of_notes, COUNT(date_of_notes) FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.first_name = "Fanny" ORDER BY COUNT(date_of_notes)
### Instruction: provide the number of patients who have the admission location as transfer from hosp/extram and diagnosis icd9 code as 4820. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND diagnoses.icd9_code = "4820"
### Instruction: A pie chart showing the number of browsers for each accelerator in the descending order of compatible year. ### Response:
SELECT T3.name, COUNT(T3.name) FROM accelerator_compatible_browser AS T1 JOIN browser AS T2 ON T1.browser_id = T2.id JOIN Web_client_accelerator AS T3 ON T1.accelerator_id = T3.id GROUP BY T3.name ORDER BY T1.compatible_since_year DESC
### 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 list in ascending by the bars. ### 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 EMAIL
### Instruction: What was the average number of people born in other EU states in millions, when the total number of foreign-born people in millions was 0.5, and when the total population in millions was less than 5.534? ### Response:
SELECT AVG(born_in_other_eu_state__millions_) FROM table_name_57 WHERE total_foreign_born__millions_ = 0.5 AND total_population__millions_ < 5.534
### Instruction: what topics does Luke Zettlemoyer publish in ### Response:
SELECT DISTINCT keyphrase.keyphraseid FROM author, keyphrase, paper, paperkeyphrase, writes WHERE author.authorname = 'Luke Zettlemoyer' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
### Instruction: What rider has laps less than 20, a ducati 1098 rs 08 as the bike, with accident as the time, and a grid less than 14? ### Response:
SELECT "Rider" FROM table_64321 WHERE "Laps" < '20' AND "Bike" = 'ducati 1098 rs 08' AND "Time" = 'accident' AND "Grid" < '14'
### Instruction: Return a bar chart on how many students are older than 20 in each dorm?, list bar from low to high order. ### Response:
SELECT dorm_name, COUNT(*) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.Age > 20 GROUP BY T3.dorm_name ORDER BY dorm_name
### Instruction: count the number of patients whose year of death is less than or equal to 2115 and drug code is glyb5? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dod_year <= "2115.0" AND prescriptions.formulary_drug_cd = "GLYB5"
### Instruction: Questions with low score and high viewcounts. ### Response:
SELECT Posts.Id AS "post_link", Posts.CreationDate, Posts.Score, Posts.ViewCount, PostHistory.CreationDate AS "ProtectedDate" FROM Posts LEFT JOIN PostHistory ON Posts.Id = PostHistory.PostId AND PostHistory.PostHistoryTypeId = 19 WHERE Posts.Score <= 2 ORDER BY Posts.ViewCount DESC LIMIT 100
### Instruction: what is the number of patients whose primary disease is squamous cell carcinoma oral tongue/sda and year of death is less than or equal to 2131? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "SQUAMOUS CELL CARCINOMA ORAL TONGUE/SDA" AND demographic.dod_year <= "2131.0"
### Instruction: when patient 3403 first got surgery in 2105. ### Response:
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3403) AND STRFTIME('%y', procedures_icd.charttime) = '2105' ORDER BY procedures_icd.charttime LIMIT 1
### Instruction: A bar chart for returning the number of the lot details of lots that belong to investors with details 'l'?, could you sort by the x-axis from high to low? ### Response:
SELECT lot_details, COUNT(lot_details) FROM Investors AS T1 JOIN Lots AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l" GROUP BY lot_details ORDER BY lot_details DESC
### Instruction: For all employees who have the letters D or S in their first name, return a bar chart about the distribution of hire_date and the average of department_id bin hire_date by time, show from high to low by the total number please. ### Response:
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(DEPARTMENT_ID) DESC
### Instruction: How much Population (2011) has a Land area (km ) larger than 15.69, and a Population density (per km ) larger than 57.3? ### Response:
SELECT SUM("Population (2011)") FROM table_62793 WHERE "Land area (km\u00b2)" > '15.69' AND "Population density (per km\u00b2)" > '57.3'
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about the sum of manufacturer over the headquarter , and group by attribute headquarter by a bar chart, could you list by the total number in ascending? ### Response:
SELECT Headquarter, SUM(Manufacturer) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter ORDER BY SUM(Manufacturer)
### Instruction: what is the number of patients whose admission type is urgent and diagnoses long title is ostium secundum type atrial septal defect? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "URGENT" AND diagnoses.long_title = "Ostium secundum type atrial septal defect"
### Instruction: For all employees who have the letters D or S in their first name, give me the comparison about the average of manager_id over the job_id , and group by attribute job_id, and could you rank X-axis from high to low order? ### 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 JOB_ID DESC
### Instruction: WHAT CANDIDATE HAD A MARGIN OF ERROR OF 4.5%, WHEN PAT TOOMEY WAS 45% AND JOE SESTAK WAS 38%? ### Response:
SELECT "Other" FROM table_50753 WHERE "Margin of error" = '± 4.5%' AND "Pat Toomey (R)" = '45%' AND "Joe Sestak (D)" = '38%'
### Instruction: For all employees who have the letters D or S in their first name, give me the comparison about the average of salary over the job_id , and group by attribute job_id by a bar chart, and rank by the Y-axis in asc. ### Response:
SELECT JOB_ID, AVG(SALARY) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY AVG(SALARY)
### Instruction: how many office admitted patients have aortic valve insufficiency/aortic valve replacement/sda primary disease? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND demographic.diagnosis = "AORTIC VALVE INSUFFIENCY\AORTIC VALVE REPLACEMENT /SDA"
### Instruction: Give the number of each course name with at least five enrollments Return a bar chart, and list by the Y-axis in ascending. ### Response:
SELECT T1.CName, COUNT(T1.CName) FROM Course AS T1 JOIN Enrolled_in AS T2 ON T1.CID = T2.CID GROUP BY T1.CName, T2.CID HAVING COUNT(*) >= 5 ORDER BY COUNT(T1.CName)
### Instruction: how many patients whose procedure icd9 code is 8674 and drug route is nu? ### 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 = "8674" AND prescriptions.route = "NU"
### Instruction: what is the date when saros is more than 124, the type is total, the magnitude is more than 1.0535 and the time (greatest) is 20:55:28? ### Response:
SELECT date FROM table_name_21 WHERE saros > 124 AND type = "total" AND magnitude > 1.0535 AND time__greatest_ = "20:55:28"
### Instruction: Just show the first name and the manager id with a bar chart, and sort total number from high to low order. ### Response:
SELECT T1.FIRST_NAME, T1.MANAGER_ID FROM employees AS T1 JOIN departments AS T2 ON T1.DEPARTMENT_ID = T2.DEPARTMENT_ID WHERE T1.EMPLOYEE_ID = T2.MANAGER_ID ORDER BY T1.MANAGER_ID DESC
### Instruction: How many trips started from Mountain View city and ended at Palo Alto city? ### Response:
SELECT COUNT(*) FROM station AS T1 JOIN trip AS T2 JOIN station AS T3 JOIN trip AS T4 ON T1.id = T2.start_station_id AND T2.id = T4.id AND T3.id = T4.end_station_id WHERE T1.city = "Mountain View" AND T3.city = "Palo Alto"
### Instruction: how many patients whose diagnoses short title is physical restrain status and drug route is 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 = "Physical restrain status" AND prescriptions.route = "NG"
### Instruction: What is Position, when Round is less than 5, when Nationality is 'Canada', and when College/Junior/Club Team (League) is 'Saint John Sea Dogs ( QMJHL )'? ### Response:
SELECT position FROM table_name_30 WHERE round < 5 AND nationality = "canada" AND college_junior_club_team__league_ = "saint john sea dogs ( qmjhl )"
### Instruction: when patient 10266 was receiving a lab test for the first time when they visited the hospital first time? ### Response:
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10266 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) ORDER BY labevents.charttime LIMIT 1
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me the trend about employee_id over hire_date with a line chart. ### Response:
SELECT HIRE_DATE, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: How many downvotes do I have for each tag?. ### Response:
SELECT TagName, COUNT(*) AS DownVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 3 WHERE Posts.OwnerUserId = '##UserId##' GROUP BY TagName ORDER BY DownVotes DESC
### Instruction: List all Comments Between Two Users. Comments from user#1 that specifically mention user#2's name, and vice versa. ### Response:
SELECT CreationDate, PostId AS "post_link", Score, Text FROM Comments WHERE (UserId = '##UserID##' AND LOWER(Text) LIKE @name2) OR (UserId = '##UserID2##' AND LOWER(Text) LIKE @name1) ORDER BY CreationDate
### Instruction: chronic inflammatory or autoimmune disease with the exception of well _ controlled hypothyroidism or intermittent or mild persistent asthma not requiring the use of daily inhaled steroids ### Response:
SELECT * FROM table_dev_4 WHERE chronic_inflammatory = 1 OR autoimmune_disease = 1 OR hypothyroidism = 1 OR asthma = 1 AND inhaled_steroids = 1
### Instruction: how many patients whose primary disease is sigmoid diverticulitis, colovestical fistula/sda and days of hospital stay is greater than 11? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "SIGMOID DIVERTICULITIS, COLOVESTICAL FISTULA/SDA" AND demographic.days_stay > "11"
### Instruction: What are the names of all the states with college students playing in the mid position but no goalies? ### Response:
SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cname = T2.cname WHERE T2.ppos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cname = T2.cname WHERE T2.ppos = 'goalie'
### Instruction: What is the salary and name of the employee who has the most number of certificates on aircrafts with distance more than 5000? ### Response:
SELECT T1.name FROM employee AS T1 JOIN certificate AS T2 ON T1.eid = T2.eid JOIN aircraft AS T3 ON T3.aid = T2.aid WHERE T3.distance > 5000 GROUP BY T1.eid ORDER BY COUNT(*) DESC LIMIT 1
### Instruction: What is the B (max) average when the C (max) is greater than 156, the taper is 1:19.231, and the D (max) is less than 34.9? ### Response:
SELECT AVG(b__max_) FROM table_name_22 WHERE c__max_ > 156 AND taper = "1:19.231" AND d__max_ < 34.9
### Instruction: For those records from the products and each product's manufacturer, show me about the distribution of name and manufacturer , and group by attribute headquarter in a bar chart, and sort by the X-axis in asc. ### Response:
SELECT T1.Name, T1.Manufacturer FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter, T1.Name ORDER BY T1.Name
### Instruction: Which Numbers (Quantity Ordered) have a Fuel Propulsion of cng, and a Year smaller than 2008, and a Make/ Model of nabi 40-lfw? ### Response:
SELECT "Numbers (Quantity Ordered)" FROM table_6428 WHERE "Fuel Propulsion" = 'cng' AND "Year" < '2008' AND "Make/ Model" = 'nabi 40-lfw'
### Instruction: Qui n pregunta m s, por a os. ### Response:
SELECT MAX(Users.DisplayName), Users.Id, COUNT(Posts.Id) FROM Users LEFT JOIN Posts ON Users.Id = Posts.OwnerUserId WHERE Posts.PostTypeId = 1 AND YEAR(Posts.CreationDate) = '##Parameter:int?2018##' GROUP BY Users.Id ORDER BY COUNT(Posts.Id) DESC LIMIT 10
### Instruction: what is the part number when the release date is january 2011, the frequency is 3.4 ghz and the release price (usd) is $317? ### Response:
SELECT "Part number(s)" FROM table_13847 WHERE "Release date" = 'january 2011' AND "Frequency" = '3.4 ghz' AND "Release price ( USD )" = '$317'
### Instruction: For all employees who have the letters D or S in their first name, return a bar chart about the distribution of hire_date and the amount of hire_date bin hire_date by weekday, and show y axis from high to low order. ### Response:
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY COUNT(HIRE_DATE) DESC
### Instruction: For those records from the products and each product's manufacturer, show me about the distribution of name and revenue , and group by attribute name in a bar chart, and I want to list by the bar in asc. ### Response:
SELECT T1.Name, T2.Revenue FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T1.Name, T1.Name ORDER BY T1.Name
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, a line chart shows the trend of commission_pct over hire_date . ### Response:
SELECT HIRE_DATE, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: give the number of patients whose discharge location is left against medical advice and procedure short title is int insert dual-cham dev. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "LEFT AGAINST MEDICAL ADVI" AND procedures.short_title = "Int insert dual-cham dev"
### Instruction: What is the Location with a Year larger than 2011, and a President with herman van rompuy (2nd term), and a Date of 28 29 june, and a Type with scheduled? ### Response:
SELECT location FROM table_name_63 WHERE year > 2011 AND president = "herman van rompuy (2nd term)" AND date = "28–29 june" AND type = "scheduled"
### Instruction: give me the number of patients whose year of birth is less than 2089 and lab test fluid is cerebrospinal fluid (csf)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "2089" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: count the number of patients whose admission type is urgent 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.admission_type = "URGENT" AND procedures.long_title = "Combined right and left heart cardiac catheterization"
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about the sum of revenue over the name , and group by attribute name by a bar chart, and rank by the Y-axis in desc. ### Response:
SELECT T2.Name, T2.Revenue FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Name ORDER BY T2.Revenue DESC
### Instruction: Find the number of customers that use email as the contact channel for each weekday Visualize with a bar chart, list in descending by the y axis. ### Response:
SELECT active_from_date, COUNT(active_from_date) FROM Customers AS t1 JOIN Customer_Contact_Channels AS t2 ON t1.customer_id = t2.customer_id WHERE t2.channel_code = 'Email' ORDER BY COUNT(active_from_date) DESC
### Instruction: how many times during their current hospital visit has patient 006-14121 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-14121' AND patient.hospitaldischargetime IS NULL)
### Instruction: Find the titles of items that received both a rating higher than 8 and a rating below 5. ### Response:
SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > 8 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5
### Instruction: Find the number of students who are older than 18 and do not have allergy to either food or animal. ### Response:
SELECT COUNT(*) FROM Student WHERE age > 18 AND NOT StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food" OR T2.allergytype = "animal")
### Instruction: Can my MDE class be MACROMOL 790 ? ### Response:
SELECT COUNT(*) > 0 FROM course, program, program_course WHERE course.department = 'MACROMOL' AND course.number = 790 AND program_course.category LIKE '%MDE%' AND program_course.course_id = course.course_id AND program.name LIKE '%CS-LSA%' AND program.program_id = program_course.program_id
### Instruction: Questions per Day - Rolling average. ### Response:
SELECT DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), DAY(CreationDate)) AS "date", COUNT(*) FROM Posts WHERE ParentId IS NULL GROUP BY YEAR(CreationDate), MONTH(CreationDate), DAY(CreationDate) ORDER BY YEAR(CreationDate), MONTH(CreationDate), DAY(CreationDate)
### Instruction: where is a good french restaurant in the yosemite and mono lake area ? ### Response:
SELECT location.house_number, restaurant.name FROM geographic, location, restaurant WHERE geographic.region = 'yosemite and mono lake area' AND restaurant.city_name = geographic.city_name AND restaurant.food_type = 'french' AND restaurant.id = location.restaurant_id AND restaurant.rating > 2.5
### Instruction: How many instructors are in each department? Show me a bar chart, sort by the x axis in asc. ### Response:
SELECT T1.dept_name, COUNT(DISTINCT T3.ID) FROM department AS T1 JOIN student AS T2 ON T1.dept_name = T2.dept_name JOIN instructor AS T3 ON T1.dept_name = T3.dept_name ORDER BY T1.dept_name
### Instruction: For those records from the products and each product's manufacturer, visualize a bar chart about the distribution of name and code , and group by attribute headquarter, and list in ascending by the Y-axis. ### Response:
SELECT T1.Name, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter, T1.Name ORDER BY T1.Code
### Instruction: how much larger was the 2009 population of chicago than the 2009 population of toronto ? ### Response:
SELECT (SELECT "csa/cma\n2009 population" FROM table_204_113 WHERE "area" = 'chicago') - (SELECT "csa/cma\n2009 population" FROM table_204_113 WHERE "area" = 'toronto')
### Instruction: provide the number of patients whose gender is m and diagnoses long title is poisoning by other opiates and related narcotics? ### 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 = "Poisoning by other opiates and related narcotics"
### Instruction: In 2014, what are the id and rank of the team that has the largest average number of attendance? ### Response:
SELECT T2.team_id, T2.rank FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id WHERE T1.year = 2014 GROUP BY T1.team_id ORDER BY AVG(T1.attendance) DESC LIMIT 1
### Instruction: What is the 1978 Veteran membership with a late 1941 macedonia and a late 1943 less than 10,000? ### Response:
SELECT SUM(1978 AS _veteran_membership) FROM table_name_66 WHERE NOT _late_1941 = "macedonia" AND late_1943 < 10 OFFSET 000
### Instruction: count the number of patients whose religion is greek orthodox and diagnoses long title is drug-induced delirium? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.religion = "GREEK ORTHODOX" AND diagnoses.long_title = "Drug-induced delirium"
### Instruction: how many patients on additive type drug prescription had sodium lab test done? ### 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.drug_type = "ADDITIVE" AND lab.label = "Sodium"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find phone_number and department_id , and visualize them by a bar chart. ### Response:
SELECT PHONE_NUMBER, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: Which Big (>500ha) has a Micro (10ha) larger than 940, and a Department of potos , and a Total smaller than 16,240? ### Response:
SELECT MAX(big__) > 500 AS ha_ FROM table_name_12 WHERE micro__10ha_ > 940 AND department = "potosí" AND total < 16 OFFSET 240
### Instruction: just count how many patients have been prescribed spironolactone in 2105. ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT prescriptions.hadm_id FROM prescriptions WHERE prescriptions.drug = 'spironolactone' AND STRFTIME('%y', prescriptions.startdate) = '2105')
### Instruction: count the number of patients whose admission year is less than 2124 and diagnoses long title is other specified disorders of skin? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2124" AND diagnoses.long_title = "Other specified disorders of skin"
### Instruction: Off topic questions in after 2015-1-1. ### Response:
SELECT p.Id FROM Posts AS p INNER JOIN PostHistory AS ph ON p.Id = ph.PostId WHERE p.PostTypeId = 1 AND p.ClosedDate = ph.CreationDate AND ph.PostHistoryTypeId = 10 AND (Comment = 102) AND p.ClosedDate > '2015-1-1'
### Instruction: how many patients whose year of death is less than or equal to 2126 and procedure icd9 code is 9229? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dod_year <= "2126.0" AND procedures.icd9_code = "9229"
### Instruction: display those employees who contain a letter z to their first name and also display their last name, city. ### Response:
SELECT T1.first_name, T1.last_name, T3.city FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id WHERE T1.first_name LIKE '%z%'
### Instruction: what is the number of patients whose age is less than 31 and diagnoses short title is crnry athrscl natve vssl? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.age < "31" AND diagnoses.short_title = "Crnry athrscl natve vssl"
### Instruction: how many patients have phys referral/normal deli as the admission location procedure icd9 code 309? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND procedures.icd9_code = "309"
### Instruction: What is the lowest To par, when Total is greater than 148, and when Year(s) Won is '1959 , 1968 , 1974'? ### Response:
SELECT MIN("To par") FROM table_60893 WHERE "Total" < '148' AND "Year(s) won" = '1959 , 1968 , 1974'
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about manufacturer over the name , and group by attribute founder, show from low to high by the Y-axis. ### Response:
SELECT T1.Name, T1.Manufacturer FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder, T1.Name ORDER BY T1.Manufacturer
### Instruction: Show all branch names with the number of members in each branch registered after 2015 Plot them as bar chart, and sort in descending by the Y please. ### Response:
SELECT Name, COUNT(*) FROM membership_register_branch AS T1 JOIN branch AS T2 ON T1.Branch_ID = T2.Branch_ID WHERE T1.Register_Year > 2015 GROUP BY T2.Branch_ID ORDER BY COUNT(*) DESC
### Instruction: Give the number of patients whose admission location is transfer from hosp/extram that had a procedure icd9 code of 40. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND procedures.icd9_code = "40"
### Instruction: how many patients whose discharge location is rehab/distinct part hosp and procedure long title is other phototherapy? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "REHAB/DISTINCT PART HOSP" AND procedures.long_title = "Other phototherapy"
### Instruction: Distribution of my questions and answers by their score. ### Response:
SELECT Posts.Score, COUNT(*) AS Number, (CASE WHEN MIN(Posts.PostTypeId) = 1 THEN 'Question' ELSE 'Answer' END) AS Type FROM Posts WHERE Posts.OwnerUserId = @UserId AND Posts.PostTypeId IN (1, 2) GROUP BY Posts.Score, Posts.PostTypeId ORDER BY Type, Score DESC
### Instruction: What were the total games in the Big Ten conference when Nebraska lost fewer than 488 games and had a Pct less than 0.7014? ### Response:
SELECT SUM("Total Games") FROM table_10674 WHERE "Conference" = 'big ten' AND "Lost" < '488' AND "Team" = 'nebraska' AND "Pct." < '0.7014'
### Instruction: For those records from the products and each product's manufacturer, a bar chart shows the distribution of name and the amount of name , and group by attribute name, and list from low to high by the Name please. ### Response:
SELECT T1.Name, COUNT(T1.Name) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T1.Name ORDER BY T1.Name