instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: what is the number of patients whose admission location is phys referral/normal deli and procedure icd9 code is 5091? ### 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 = "5091"
### Instruction: how many patients of black/african american ethnicity were diagnosed with icd9 code 34982? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "BLACK/AFRICAN AMERICAN" AND diagnoses.icd9_code = "34982"
### Instruction: What is the amount of trees, that require replacement when prevailing types, % is pine 29.37 poplar 26.12 acer negundo 13.2? ### Response:
SELECT "Amount of trees, that require replacement" FROM table_72089 WHERE "Prevailing types, %" = 'Pine — 29.37 Poplar — 26.12 Acer negundo — 13.2'
### Instruction: Limiting Posts by Date and Rep, Parameterized (Tutorial). ### Response:
SELECT p.Title, p.Id, u.DisplayName, u.Reputation FROM Posts AS p JOIN Users AS u ON p.OwnerUserId = u.Id WHERE p.CreationDate BETWEEN '##StartDate:string##' AND '##EndDate:string##' AND p.PostTypeId = 1 AND u.Reputation < '##MaxReputation:int##'
### Instruction: For those employees who was hired before 2002-06-21, return a bar chart about the distribution of job_id and the sum of manager_id , and group by attribute job_id, list from low to high by the names. ### Response:
SELECT JOB_ID, SUM(MANAGER_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: how many of the patients admitted on phys referral/normal deli were treated with dilt30? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND prescriptions.formulary_drug_cd = "DILT30"
### Instruction: likely obsolete comments on posts from users who've left. ### Response:
SELECT Id FROM Posts AS p WHERE (OwnerUserId IS NULL OR (SELECT DATEDIFF(d, LastAccessDate, GETDATE()) FROM Users AS u WHERE p.OwnerUserId = u.Id) > 360) AND CommunityOwnedDate IS NULL AND CommentCount > 4 AND LastEditDate > (SELECT MAX(CreationDate) FROM Comments WHERE PostId = p.Id)
### Instruction: count the number of patients whose admission year is less than 2195 and drug name is neo*iv*fat emulsion? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admityear < "2195" AND prescriptions.drug = "NEO*IV*Fat Emulsion"
### 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: count the number of patients whose admission location is trsf within this facility and drug code is foli 1. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "TRSF WITHIN THIS FACILITY" AND prescriptions.formulary_drug_cd = "FOLI1"
### 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: Can I take the 314 course next term ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 314 AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### 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: For all employees who have the letters D or S in their first name, give me the comparison about the amount of hire_date over the hire_date bin hire_date by weekday by a bar chart, sort by the y axis from high to low. ### 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: Unanswered and uncommented questions for Worklight. ### Response:
SELECT pt.PostId AS "post_link", p.Score, p.ViewCount, p.CommentCount, p.CreationDate FROM Tags AS t, PostTags AS pt, Posts AS p WHERE pt.TagId = t.Id AND p.Id = pt.PostId AND t.TagName = 'worklight' AND p.AnswerCount IS NULL AND p.CommentCount IS NULL ORDER BY CreationDate
### Instruction: what is the number of patients whose admission year is less than 2178 and procedure long title is continuous intra-arterial blood gas monitoring? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2178" AND procedures.long_title = "Continuous intra-arterial blood gas monitoring"
### Instruction: 100 high-scoring posts (Concise edition). A concise edition of http://data.stackexchange.com/stackoverflow/query/504298/100-high-scoring-posts, with only the ID, votes and titles and views (for questions). You can choose a minimum score yourself. ### Response:
SELECT Title, Id, Score, ViewCount FROM Posts WHERE Score >= '##MinScore:int##' LIMIT 100
### Instruction: For those employees who did not have any job in the past, show me about the distribution of hire_date and the average of salary bin hire_date by weekday in a bar chart, could you show in desc by the total number? ### Response:
SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(SALARY) DESC
### Instruction: give me the number of patients whose primary disease is mesenteric ischemia 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.diagnosis = "MESENTERIC ISCHEMIA" AND procedures.short_title = "Chordae tendineae ops"
### Instruction: how many days have elapsed since the time patient 739 was admitted to the icu? ### 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 = 739) AND icustays.outtime IS NULL
### Instruction: what is the number of patients whose admission location is clinic referral/premature and primary disease is brain mass;intracranial hemorrhage? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND demographic.diagnosis = "BRAIN MASS;INTRACRANIAL HEMORRHAGE"
### Instruction: For those records from the products and each product's manufacturer, find headquarter and the average of manufacturer , and group by attribute headquarter, and visualize them by a bar chart, and could you order in descending by the X? ### Response:
SELECT Headquarter, AVG(Manufacturer) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter ORDER BY Headquarter DESC
### Instruction: What are the purchase details of transactions with amount bigger than 10000, and count them by a bar chart, show by the names in ascending. ### Response:
SELECT purchase_details, COUNT(purchase_details) FROM Purchases AS T1 JOIN Transactions AS T2 ON T1.purchase_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction > 10000 GROUP BY purchase_details ORDER BY purchase_details
### Instruction: until 2100 what are the top five most commonly prescribed drugs? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE STRFTIME('%y', medication.drugstarttime) <= '2100' GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
### Instruction: give the number of patients whose procedure icd9 code is 331 and drug route is sc. ### 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 = "331" AND prescriptions.route = "SC"
### Instruction: TOP 100 Bosnians on StackOverflow. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation, UpVotes, DownVotes, Views, Location, AboutMe, WebsiteUrl FROM Users WHERE LOWER(Location) LIKE '%bosnia%' OR LOWER(Location) LIKE '%bosna%' OR Location LIKE '% BiH%' ORDER BY Reputation DESC LIMIT 100
### Instruction: What are the facility codes of the apartments with more than four bedrooms, and count them by a bar chart, and I want to display in ascending by the facility_code. ### Response:
SELECT facility_code, COUNT(facility_code) FROM Apartment_Facilities AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.bedroom_count > 4 GROUP BY facility_code ORDER BY facility_code
### Instruction: provide the number of patients whose year of death is less than or equal to 2148 and procedure short title is percu endosc gastrostomy? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dod_year <= "2148.0" AND procedures.short_title = "Percu endosc gastrostomy"
### Instruction: Men's singles of k stutis navickas, and a Women's singles of ugn urbonait , and a Year larger than 2004 involved which mens double? ### Response:
SELECT "Men's doubles" FROM table_38046 WHERE "Men's singles" = 'kęstutis navickas' AND "Women's singles" = 'ugnė urbonaitė' AND "Year" > '2004'
### Instruction: List all characteristics of product named 'sesame' with type code 'Grade'. ### Response:
SELECT t3.characteristic_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN characteristics AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t1.product_name = "sesame" AND t3.characteristic_type_code = "Grade"
### Instruction: How many patients with aortic valve insuffiency/aortic valve replacement /sda as their primary disease were born before the year 2076? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "AORTIC VALVE INSUFFIENCY\AORTIC VALVE REPLACEMENT /SDA" AND demographic.dob_year < "2076"
### Instruction: Among the patients who had a closed endoscopic biopsy of bronchus, how many of them stayed at the hospital for more than 1 day? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.days_stay > "1" AND procedures.long_title = "Closed [endoscopic] biopsy of bronchus"
### Instruction: count the number of patients whose admission location is emergency room admit and diagnoses icd9 code is 70722? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_location = "EMERGENCY ROOM ADMIT" AND diagnoses.icd9_code = "70722"
### Instruction: for a Goals Against smaller than 9, and a Goal Differential of 0, and a Draws smaller than 2, and a Wins of 1, what's the goal total? ### Response:
SELECT SUM("Goals For") FROM table_67174 WHERE "Goals Against" < '9' AND "Goal Differential" = '0' AND "Draws" < '2' AND "Wins" = '1'
### Instruction: What is the highest pjuehun with a kenema greater than 559, a kambia of 45,653, and a tonkolili greater than 113,926? ### Response:
SELECT MAX(pujehun) FROM table_name_9 WHERE kenema > 559 AND kambia = "45,653" AND tonkolili > 113 OFFSET 926
### Instruction: What is the number of patients diagnosed with below knee amputation status who have a delta abnormal lab test? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.short_title = "Status amput below knee" AND lab.flag = "delta"
### Instruction: Votes distribution of regular users who have cast votes. ### Response:
SELECT VotesFloor, COUNT(*) AS UserCount FROM (SELECT FLOOR((UpVotes + DownVotes) / @Interval) * @Interval AS VotesFloor FROM Users WHERE UpVotes + DownVotes > 0 AND Id > 0) AS Hist WHERE @IsRemoveLeast != 1 OR (VotesFloor != 0) GROUP BY VotesFloor ORDER BY VotesFloor DESC
### Instruction: Which Purpose has an Elevation + Height of 0 + metres (ft), a Location of bikini, namu (charlie), and a Yield of 220 kt? ### Response:
SELECT "Purpose" FROM table_11765 WHERE "Elevation + Height" = '0 + metres (ft)' AND "Location" = 'bikini, namu (charlie)' AND "Yield" = '220 kt'
### Instruction: Answers with the most downs. ### Response:
SELECT Posts.Id AS "post_link", Posts.Id AS Id, MIN(Posts.Score) AS Score, COUNT(*) AS Downs FROM Posts, Votes WHERE Posts.PostTypeId = 2 AND Votes.VoteTypeId = 3 AND Votes.PostId = Posts.Id GROUP BY Posts.Id ORDER BY Downs DESC, Posts.Id LIMIT 100
### Instruction: count the number of patients whose ethnicity is black/cape verdean and drug name is psyllium wafer? ### 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.drug = "Psyllium Wafer"
### Instruction: Who was the opposing team when the scorers were jong-a-pin 19'( o.g. ) , gattuso 23' , inzaghi 69'? ### Response:
SELECT "Opponent team" FROM table_45082 WHERE "Scorers" = 'jong-a-pin 19''( o.g. ) , gattuso 23'' , inzaghi 69'
### Instruction: Which Land area (km ) has a Population density (per km ) larger than 112.6, and a Population (2006) larger than 785, and a Name of pinehouse? ### Response:
SELECT MAX(land_area__km²_) FROM table_name_12 WHERE population_density__per_km²_ > 112.6 AND population__2006_ > 785 AND name = "pinehouse"
### 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: provide the number of patients whose discharge location is home health care and procedure short title is open incis hern-grft nec? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "HOME HEALTH CARE" AND procedures.short_title = "Open incis hern-grft NEC"
### Instruction: retrieve the top five most commonly prescribed medications in 2104? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE STRFTIME('%y', medication.drugstarttime) = '2104' GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
### 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: For all employees who have the letters D or S in their first name, show me about the distribution of hire_date and the sum of department_id bin hire_date by time in a bar chart, display in desc by the sum department id. ### Response:
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY SUM(DEPARTMENT_ID) DESC
### 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: Got all 6 steward badges, in chronological order. It works correctly only on the sites where exactly 6 review queues are existing ### Response:
SELECT MIN(Users.Id) AS "user_link", MAX(Badges.Date) FROM Badges LEFT JOIN Users ON Badges.UserId = Users.Id WHERE Badges.Name = 'Steward' GROUP BY Badges.UserId HAVING COUNT(*) = 6 ORDER BY MAX(Badges.Date)
### Instruction: how many patients are diagnosed with complete kidney transplant and tested with ascites in lab? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.short_title = "Compl kidney transplant" AND lab.fluid = "Ascites"
### Instruction: is captopril prescribed since 2103 to patient 2518? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2518) AND prescriptions.drug = 'captopril' AND STRFTIME('%y', prescriptions.startdate) >= '2103'
### Instruction: For those employees who did not have any job in the past, give me the comparison about the average of manager_id over the hire_date bin hire_date by time, sort in descending by the total number. ### Response:
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(MANAGER_ID) DESC
### Instruction: what were the five medicines most frequently prescribed since 2102? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE STRFTIME('%y', medication.drugstarttime) >= '2102' GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
### Instruction: provide the number of patients whose admission type is emergency 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.admission_type = "EMERGENCY" AND diagnoses.short_title = "Crnry athrscl natve vssl"
### 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 hire_date bin hire_date by time by a bar chart, I want to list in ascending by the Y-axis. ### Response:
SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(SALARY)
### Instruction: count the number of patients who were prematurely admitted via clinic referral and had procedure icd9 code 3892. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND procedures.icd9_code = "3892"
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about the average of code over the headquarter , and group by attribute headquarter, and order from low to high by the X. ### 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
### 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 salary , and group by attribute job_id, show in asc by the y axis. ### Response:
SELECT JOB_ID, SUM(SALARY) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY SUM(SALARY)
### Instruction: other tags on Excel questions. ### Response:
SELECT TagName, TagId, COUNT(*) AS cnt FROM PostTags AS pt LEFT JOIN Tags AS t ON pt.TagId = t.Id WHERE PostId IN (SELECT pt2.PostId FROM PostTags AS pt2 LEFT JOIN Tags AS t2 ON pt2.TagId = t2.Id WHERE t2.TagName LIKE '%excel%') GROUP BY TagId, TagName HAVING COUNT(*) > 1 ORDER BY cnt DESC
### Instruction: how many times have patient 76275 been to the icu on their last hospital encounter? ### Response:
SELECT COUNT(DISTINCT icustays.icustay_id) FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 76275 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)
### Instruction: For those employees who was hired before 2002-06-21, give me the comparison about the sum of salary over the job_id , and group by attribute job_id, and could you rank by the x axis in desc? ### Response:
SELECT JOB_ID, SUM(SALARY) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID DESC
### Instruction: give me the number of patients whose year of birth is less than 2101 and diagnoses short title is ac posthemorrhag anemia? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dob_year < "2101" AND diagnoses.short_title = "Ac posthemorrhag anemia"
### Instruction: For those records from the products and each product's manufacturer, show me about the distribution of name and the sum of manufacturer , and group by attribute name in a bar chart, order by the y-axis from low to high. ### Response:
SELECT T1.Name, T1.Manufacturer FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T1.Name ORDER BY T1.Manufacturer
### Instruction: how many patients diagnosed with alkalosis have been prescribed main drug type? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Alkalosis" AND prescriptions.drug_type = "MAIN"
### Instruction: For each year, bin the year into day of the week interval, and return the total number of times the team Boston Red Stockings won in the postseasons using a line chart, sort by the x axis in desc. ### Response:
SELECT year, SUM(COUNT(*)) FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' ORDER BY year DESC
### Instruction: For those records from the products and each product's manufacturer, show me about the distribution of founder and the sum of manufacturer , and group by attribute founder in a bar chart, and could you display from high to low by the y-axis? ### Response:
SELECT Founder, SUM(Manufacturer) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder ORDER BY SUM(Manufacturer) DESC
### Instruction: For all the claims whose claimed amount is larger than the average, bin the settlement date into the day of week interval and count them for visualizing a bar chart, display y-axis in descending order. ### Response:
SELECT Date_Claim_Settled, COUNT(Date_Claim_Settled) FROM Claims WHERE Amount_Claimed > (SELECT AVG(Amount_Claimed) FROM Claims) ORDER BY COUNT(Date_Claim_Settled) DESC
### Instruction: For those records from the products and each product's manufacturer, visualize a bar chart about the distribution of name and the amount of name , and group by attribute name, display by the y-axis in descending. ### 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 COUNT(T1.Name) DESC
### Instruction: How many of the patients with hypoxemia were treated with base drug? ### 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 = "Hypoxemia" AND prescriptions.drug_type = "BASE"
### Instruction: What is the FCC info for the call sign with a frequency MHz of 101.3, a ERP W over 10, and a Facility ID smaller than 87027? ### Response:
SELECT "FCC info" FROM table_33300 WHERE "Frequency MHz" = '101.3' AND "ERP W" > '10' AND "Facility ID" < '87027'
### Instruction: List the names of all the distinct customers who bought a keyboard. ### Response:
SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id JOIN products AS T4 ON T3.product_id = T4.product_id WHERE T4.product_name = "keyboard"
### Instruction: when did patient 005-76912 get in the hospital this year for the first time? ### Response:
SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '005-76912' AND DATETIME(patient.hospitaladmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY patient.hospitaladmittime LIMIT 1
### Instruction: Which employee manage most number of peoples? List employee's first and last name, and number of people report to that employee. ### Response:
SELECT T2.first_name, T2.last_name, COUNT(T1.reports_to) FROM employees AS T1 JOIN employees AS T2 ON T1.reports_to = T2.id GROUP BY T1.reports_to ORDER BY COUNT(T1.reports_to) DESC LIMIT 1
### Instruction: What is the Col (m) of Peak Mount Aragats with an Elevation (m) larger than 3,905 and Prominence smaller than 2,143? ### Response:
SELECT MAX("Col (m)") FROM table_79479 WHERE "Elevation (m)" > '3,905' AND "Peak" = 'mount aragats' AND "Prominence (m)" < '2,143'
### Instruction: keyphrases used by Kaiming He ### Response:
SELECT DISTINCT keyphrase.keyphraseid FROM author, keyphrase, paper, paperkeyphrase, writes WHERE author.authorname = 'Kaiming He' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
### Instruction: For those employees who did not have any job in the past, show me about the distribution of hire_date and the average of salary bin hire_date by weekday in a bar chart, sort by the y-axis in ascending. ### Response:
SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(SALARY)
### Instruction: which Name has a Loss larger than 2, and a Avg/G larger than -16, and a GP-GS of 11 7, and a Gain larger than 86? ### Response:
SELECT "Name" FROM table_44241 WHERE "Loss" > '2' AND "Avg/G" > '-16' AND "GP-GS" = '11–7' AND "Gain" > '86'
### Instruction: provide the number of patients whose discharge location is home health care and procedure short title is opn mitral valvuloplasty? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "HOME HEALTH CARE" AND procedures.short_title = "Opn mitral valvuloplasty"
### Instruction: what is the number of patients whose admission year is less than 2179 and diagnoses icd9 code is 99591? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2179" AND diagnoses.icd9_code = "99591"
### Instruction: What is the average population of the region with a density less than 487, a rank of 9, and an area larger than 377,944? ### Response:
SELECT AVG("Population") FROM table_68905 WHERE "Density (Pop. per km 2 )" < '487' AND "Rank" = '9' AND "Area (km 2 )" > '377,944'
### Instruction: give me the number of patients whose admission type is emergency and diagnoses long title is glucocorticoid deficiency? ### 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 = "Glucocorticoid deficiency"
### Instruction: What is the county when the value for Others% is 1.1%, and the value for Kerry# is greater than 19,177, and the value for Bush% is 52.1%? ### Response:
SELECT "County" FROM table_15686 WHERE "Others%" = '1.1%' AND "Kerry#" > '19,177' AND "Bush%" = '52.1%'
### Instruction: what is the number of patients whose primary disease is brain mass;intracranial hemorrhage and lab test fluid is blood? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "BRAIN MASS;INTRACRANIAL HEMORRHAGE" AND lab.fluid = "Blood"
### 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