instruction
stringlengths
57
490
output
stringlengths
69
1.29k
### Instruction: give me the number of patients whose primary disease is left femur fracture and procedure icd9 code is 8848? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "LEFT FEMUR FRACTURE" AND procedures.icd9_code = "8848"
### Instruction: For all employees who have the letters D or S in their first name, give me the comparison about the sum of salary over the job_id , and group by attribute job_id, and order y-axis in asc order. ### Response:
SELECT JOB_ID, SUM(SALARY) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY SUM(SALARY)
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about price over the name , and group by attribute headquarter by a bar chart, rank by the X in desc. ### Response:
SELECT T1.Name, T1.Price FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter, T1.Name ORDER BY T1.Name DESC
### Instruction: count the number of patients whose admission type is urgent and drug name is diphenhydramine hcl? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_type = "URGENT" AND prescriptions.drug = "DiphenhydrAMINE HCl"
### Instruction: when was patient 75658 discharged from the hospital in the previous year for the first time? ### Response:
SELECT admissions.dischtime FROM admissions WHERE admissions.subject_id = 75658 AND DATETIME(admissions.dischtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY admissions.dischtime LIMIT 1
### Instruction: how many patients have had a other microbiology test since 2104? ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT microlab.patientunitstayid FROM microlab WHERE microlab.culturesite = 'other' AND STRFTIME('%y', microlab.culturetakentime) >= '2104')
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, what is the relationship between employee_id and manager_id ? ### Response:
SELECT EMPLOYEE_ID, MANAGER_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of first_name and department_id . ### Response:
SELECT FIRST_NAME, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: PHP questions waiting to be reviewed. ### Response:
SELECT COUNT(1) FROM (SELECT Posts.Id FROM Votes JOIN Posts ON Votes.PostId = Posts.Id JOIN PostTags ON Posts.Id = PostTags.PostId JOIN Tags ON PostTags.TagId = Tags.Id WHERE Posts.ClosedDate IS NULL AND VoteTypeId = 6 AND TagName = 'php' GROUP BY Posts.Id) AS Foo
### Instruction: How many Goals have Games smaller than 6, and a Debut year of 1939, and Years at club of 1939, 1941? ### Response:
SELECT COUNT("Goals") FROM table_14165 WHERE "Games" < '6' AND "Debut year" = '1939' AND "Years at club" = '1939, 1941'
### Instruction: What percentage of the population is below 50% of the median income in the region where 10.4% of the population earns below 40% of the median income? ### Response:
SELECT COUNT(below_50_percentage_of_median_income) FROM table_25042332_16 WHERE below_40_percentage_of_median_income = "10.4%"
### Instruction: What is the number of emergency hospital admitted patients who take sodium polystyrene sulfonate? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND prescriptions.drug = "Sodium Polystyrene Sulfonate"
### Instruction: what is the number of patients whose year of birth is less than 2130 and diagnoses short title is chest pain nec? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dob_year < "2130" AND diagnoses.short_title = "Chest pain NEC"
### Instruction: A bar chart for finding the number of the names of Japanese constructors that have once earned more than 5 points?, order in asc by the y axis please. ### Response:
SELECT name, COUNT(name) FROM constructors AS T1 JOIN constructorStandings AS T2 ON T1.constructorId = T2.constructorId WHERE T1.nationality = "Japanese" AND T2.points > 5 GROUP BY name ORDER BY COUNT(name)
### Instruction: how many patients whose primary disease is cerebral aneurysm/sda and drug route is ih? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "CEREBRAL ANEURYSM/SDA" AND prescriptions.route = "IH"
### Instruction: Give me a histogram for how many engineers did each staff contact? List both the contact staff name and number of engineers contacted, and I want to order from low to high by the bars. ### Response:
SELECT staff_name, COUNT(*) FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id GROUP BY T1.staff_name ORDER BY staff_name
### Instruction: had patient 99647 ever taken a laboratory test since 12/2102? ### Response:
SELECT COUNT(*) > 0 FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 99647) AND STRFTIME('%y-%m', labevents.charttime) >= '2102-12'
### Instruction: they won the game against the dragons on june 8 . what was the previous team they beat before that ? ### Response:
SELECT "opponent" FROM table_204_123 WHERE "date" < (SELECT "date" FROM table_204_123 WHERE "date" = 'saturday, june 8') AND "results\nfinal score" = 'w' ORDER BY "date" DESC LIMIT 1
### Instruction: Which courses are easiest ? ### Response:
SELECT DISTINCT course.name, course.number, program_course.workload FROM course INNER JOIN program_course ON program_course.course_id = course.course_id WHERE course.department = 'EECS' AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM program_course AS PROGRAM_COURSEalias1)
### Instruction: how many of the patients with icd9 code 4254 were dead/expired on discharge? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.discharge_location = "DEAD/EXPIRED" AND diagnoses.icd9_code = "4254"
### Instruction: List the number of each company whose office is in the building in a bar chart, list by the x-axis in asc. ### Response:
SELECT T3.name, COUNT(T3.name) FROM Office_locations AS T1 JOIN buildings AS T2 ON T1.building_id = T2.id JOIN Companies AS T3 ON T1.company_id = T3.id GROUP BY T3.name ORDER BY T3.name
### Instruction: questions with tags SQL and javascript that have code snippets. ### Response:
SELECT CAST(Id AS TEXT(20)) + '<postid>' + Body FROM Posts AS Question WHERE Question.Tags LIKE '%javascript%' AND Question.Body LIKE '%<code>%' AND PostTypeId = 1 AND question.CreationDate BETWEEN @STARTDATE AND @ENDDATE AND NOT AcceptedAnswerId IS NULL AND Score > 0 ORDER BY Id
### Instruction: For those records from the products and each product's manufacturer, show me about the distribution of name and the average of price , and group by attribute name in a bar chart, list by the mean price in ascending please. ### Response:
SELECT T1.Name, T1.Price FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T1.Name ORDER BY T1.Price
### Instruction: how many patients diagnosed with heart valve replacement by transplant left against medical advice? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.discharge_location = "LEFT AGAINST MEDICAL ADVI" AND diagnoses.long_title = "Heart valve replaced by transplant"
### Instruction: How much Elevation (m) has a Col (m) smaller than 562, and a Rank of 10, and a Prominence (m) larger than 1,598? ### Response:
SELECT COUNT(elevation__m_) FROM table_name_15 WHERE col__m_ < 562 AND rank = 10 AND prominence__m_ > 1 OFFSET 598
### Instruction: Members by Age and Reputation, oldest first. StackOverflow members from oldest to youngest, by reputation over 1000. ### Response:
SELECT Id, DisplayName, Age, Reputation, CreationDate, LastAccessDate, 'http://stackoverflow.com/users/' + CAST(Id AS TEXT) AS Url FROM Users WHERE NOT Age IS NULL AND Reputation > 1000 ORDER BY CreationDate DESC, Reputation DESC
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, return a bar chart about the distribution of job_id and department_id . ### Response:
SELECT JOB_ID, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: find out the number of patients with procedure icd9 code 9961 who have been discharged to skilled nursing facility. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "SNF" AND procedures.icd9_code = "9961"
### Instruction: For those records from the products and each product's manufacturer, draw a bar chart about the distribution of founder and the average of code , and group by attribute founder, display y-axis in ascending order please. ### Response:
SELECT T2.Founder, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Founder ORDER BY T1.Code
### Instruction: Which Network is on a Vid otron (Gatineau) channel lower than 8 and a Rogers Cable (Ottawa) channel lower than 8 and has a Call Sign of cjoh-dt? ### Response:
SELECT network FROM table_name_26 WHERE vidéotron__gatineau_ < 8 AND rogers_cable__ottawa_ < 8 AND call_sign = "cjoh-dt"
### Instruction: what was the last type of hospital admission of patient 006-123134 since 2105. ### Response:
SELECT patient.hospitaladmitsource FROM patient WHERE patient.uniquepid = '006-123134' AND STRFTIME('%y', patient.hospitaladmittime) >= '2105' ORDER BY patient.hospitaladmittime DESC LIMIT 1
### Instruction: give me the number of patients whose days of hospital stay is greater than 0 and drug name is heparin (iabp)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.days_stay > "0" AND prescriptions.drug = "Heparin (IABP)"
### Instruction: Count of dupe vs. count of exact dupes. ### Response:
SELECT COUNT(*) AS DupeCount, COUNT(CASE WHEN Orig.Body = Dupe.Body THEN 1 END) AS SameDupeCount FROM PostLinks, Posts AS Orig, Posts AS Dupe WHERE PostLinks.LinkTypeId = 3 AND Dupe.Id = PostLinks.PostId AND Orig.Id = PostLinks.RelatedPostId
### Instruction: Provide the number of american indian/alaska native ethnic background patients who had a pco2 lab test. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND lab.label = "pCO2"
### Instruction: Which producer has worked with the most number of directors ? ### Response:
SELECT producer.name FROM directed_by, director, made_by, movie, producer WHERE director.did = directed_by.did AND movie.mid = directed_by.msid AND movie.mid = made_by.msid AND producer.pid = made_by.pid GROUP BY producer.name ORDER BY COUNT(DISTINCT (director.name)) DESC LIMIT 1
### Instruction: what are the costs of a reticulocyte count, automated lab test? ### Response:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'labevents' AND cost.event_id IN (SELECT labevents.row_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'reticulocyte count, automated'))
### Instruction: What is the population of polish where guberniya is grodno? ### Response:
SELECT MIN("Polish (\u041f\u043e\u043b\u044c\u0441\u043a\u0456\u0439)") FROM table_26779 WHERE "Guberniya *" = 'Grodno'
### Instruction: If length is ft (m) with numbers of 6600-6684 (84 buses) for 2003, what is the engine type? ### Response:
SELECT "Engine Type" FROM table_55002 WHERE "Length" = 'ft (m)' AND "Year" = '2003' AND "Numbers" = '6600-6684 (84 buses)'
### Instruction: What is the average market value with a revenue greater than 6.2, a Company of national bank of greece, and a Rank smaller than 1? ### Response:
SELECT AVG("Market value (US$ billion)") FROM table_70117 WHERE "Revenues (US$ billion)" > '6.2' AND "Company" = 'national bank of greece' AND "Rank" < '1'
### Instruction: what is the time when laps is less than 21, manufacturer is aprilia, grid is less than 17 and the rider is thomas luthi? ### Response:
SELECT "Time" FROM table_44332 WHERE "Laps" < '21' AND "Manufacturer" = 'aprilia' AND "Grid" < '17' AND "Rider" = 'thomas luthi'
### Instruction: List the name and phone number of all suppliers in the alphabetical order of their addresses. ### Response:
SELECT T1.supplier_name, T1.supplier_phone FROM Suppliers AS T1 JOIN supplier_addresses AS T2 ON T1.supplier_id = T2.supplier_id JOIN addresses AS T3 ON T2.address_id = T3.address_id ORDER BY T3.address_details
### Instruction: what is the number of patients whose admission type is elective and diagnoses short title is await organ transplnt st? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND diagnoses.short_title = "Await organ transplnt st"
### Instruction: provide the number of patients whose ethnicity is hispanic or latino and drug type is main? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "HISPANIC OR LATINO" AND prescriptions.drug_type = "MAIN"
### Instruction: Which smallest interview number had a swimsuit stat of less than 9.322, an evening gown score of more than 9.259, and an average number of 9.321? ### Response:
SELECT MIN(interview) FROM table_name_71 WHERE swimsuit < 9.322 AND evening_gown > 9.259 AND average = 9.321
### Instruction: Total DTD (Range) 'google-classroom' Tag + 'classroom' in Title. ### Response:
SELECT Id AS "post_link", CreationDate, Tags FROM Posts WHERE Title LIKE '%classroom%' AND Posts.Tags COLLATE SQL_Latin1_General_CP1_CI_AS LIKE '%google-classroom%' AND CreationDate BETWEEN @StartDate AND @EndDate ORDER BY CreationDate
### Instruction: give me the number of patients whose days of hospital stay is greater than 17 and diagnoses short title is defibrination syndrome? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.days_stay > "17" AND diagnoses.short_title = "Defibrination syndrome"
### Instruction: What is the average for 2009 when 2001 is more than 0, 1996 is less than 1 and 2004 is more than 2 ### Response:
SELECT AVG("2009") FROM table_67533 WHERE "2001" > '0' AND "1996" < '1' AND "2004" > '2'
### Instruction: count the number of patients whose insurance is self pay and diagnoses long title is other hamartoses, not elsewhere classified? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.insurance = "Self Pay" AND diagnoses.long_title = "Other hamartoses, not elsewhere classified"
### Instruction: What was the emission rating in Mid-Atlantic South for the vehicle that was rated 300 g/mi (186 g/km) in the Midwest? ### Response:
SELECT mid_atlantic_south__washington, _dc_ FROM table_16105186_2 WHERE midwest__des_moines_ = "300 g/mi (186 g/km)"
### Instruction: Give me a group line chart showing the number of documents in different ending date The x-axis is ending date and group by location code, I want to order in descending by the X-axis please. ### Response:
SELECT Date_in_Locaton_To, COUNT(Date_in_Locaton_To) FROM Document_Locations GROUP BY Location_Code, Date_in_Locaton_To ORDER BY Date_in_Locaton_To DESC
### Instruction: did patient 27703 go to an emergency room during this year? ### Response:
SELECT COUNT(*) > 0 FROM admissions WHERE admissions.subject_id = 27703 AND admissions.admission_location = 'emergency room admit' AND DATETIME(admissions.admittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: give me the number of patients whose religion is christian scientist and lab test name is immunoglobulin g? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.religion = "CHRISTIAN SCIENTIST" AND lab.label = "Immunoglobulin G"
### Instruction: What is the average age for each dorm and what are the names of each dorm. Plot them as bar chart. ### 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
### Instruction: how many drugs is patient 26777 ordered until 109 months ago? ### Response:
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26777) AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-109 month')
### Instruction: How many professors for each first name? Show me a bar chart, could you display Y-axis from low to high order? ### Response:
SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM PROFESSOR AS T1 JOIN EMPLOYEE AS T2 ON T1.EMP_NUM = T2.EMP_NUM GROUP BY EMP_FNAME ORDER BY COUNT(EMP_FNAME)
### Instruction: Owners of the most yearling badges. ### Response:
SELECT Users.Id AS "user_link", Users.Id, Users.Reputation, COUNT(*) OVER (PARTITION BY Users.Id) AS Count, Badges.Date FROM Badges, Users WHERE Badges.Name = 'Yearling' AND Badges.UserId = Users.Id ORDER BY Count DESC, Users.Reputation, Users.Id, Badges.Date
### Instruction: find candidates for Reversal badge. finds open questions with score <= -5 ### Response:
SELECT Id AS "post_link", Score, ViewCount AS Views, AnswerCount AS Answers, Body FROM Posts WHERE AcceptedAnswerId IS NULL AND PostTypeId = 1 AND ClosedDate IS NULL AND Score <= -5 AND Tags LIKE '%<' + LOWER(@tag) + '>%' LIMIT 1000
### Instruction: What's the total number of FA Cup with a Play-offs of 3, and the Name of Mitch Cook Category:Articles with hCards and has a Total thats less than 11? ### Response:
SELECT COUNT("FA Cup") FROM table_70269 WHERE "Play-offs" = '3' AND "Name" = 'mitch cook category:articles with hcards' AND "Total" < '11'
### Instruction: count the number of patients whose admission location is emergency room admit and item id is 50902? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admission_location = "EMERGENCY ROOM ADMIT" AND lab.itemid = "50902"
### Instruction: provide the number of patients whose admission type is elective and diagnoses icd9 code is 4373? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND diagnoses.icd9_code = "4373"
### Instruction: give me the number of patients whose discharge location is home health care and procedure short title is sm bowel exteriorization? ### 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 = "Sm bowel exteriorization"
### Instruction: At the rate where 1800 kwh/kwp y is 1.1, what is the value of 2400 kwh/kwp y? ### Response:
SELECT "2400 kWh/kWp\u2022y" FROM table_18913 WHERE "1800 kWh/kWp\u2022y" = '1.1'
### Instruction: A line chart for showing the number of the dates of transactions if the share count is bigger than 100 or the amount is bigger than 1000, and display x-axis from low to high order. ### Response:
SELECT date_of_transaction, COUNT(date_of_transaction) FROM Transactions WHERE share_count > 100 OR amount_of_transaction > 1000 ORDER BY date_of_transaction
### Instruction: Top 50 Users from Ahmedabad.. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "http://stackoverflow.com/users/1844392/piyush", Reputation FROM Users WHERE LOWER(Location) LIKE '%ahmedabad%' OR UPPER(Location) LIKE '%AHMEDABAD' ORDER BY Reputation DESC LIMIT 50
### Instruction: A bar chart about what are the total number of credits offered by each department?, and I want to display bar from low to high order. ### Response:
SELECT DEPT_CODE, SUM(T1.CRS_CREDIT) FROM COURSE AS T1 JOIN CLASS AS T2 ON T1.CRS_CODE = T2.CRS_CODE GROUP BY T1.DEPT_CODE ORDER BY DEPT_CODE
### Instruction: For each record in schedule, show average of the price for each day in a bar chart, and order x-axis in ascending order. ### Response:
SELECT Date, AVG(Price) FROM schedule AS T1 JOIN film AS T2 ON T1.Film_ID = T2.Film_ID JOIN cinema AS T3 ON T1.Cinema_ID = T3.Cinema_ID GROUP BY Date ORDER BY Date
### Instruction: what is at 7:00 am when at 12:30 pm, 8:00 am and 7:30 am is local programs? ### Response:
SELECT "7:00 am" FROM table_12623 WHERE "12:30 pm" = 'local programs' AND "8:00 am" = 'local programs' AND "7:30 am" = 'local programs'
### Instruction: what is the number of patients whose admission type is emergency and procedure long title is colostomy, not otherwise specified? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND procedures.long_title = "Colostomy, not otherwise specified"
### Instruction: provide the number of patients whose age is less than 55 and procedure short title is aortocor bypas-1 cor art? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.age < "55" AND procedures.short_title = "Aortocor bypas-1 cor art"
### Instruction: What was their position when the score of B was less than 9.05, a total was 15.275, and A Score larger than 6.4? ### Response:
SELECT AVG("Position") FROM table_65550 WHERE "B Score" < '9.05' AND "Total" = '15.275' AND "A Score" > '6.4'
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about the average of revenue over the founder , and group by attribute founder by a bar chart, show by the x-axis in asc. ### Response:
SELECT Founder, AVG(Revenue) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder ORDER BY Founder
### Instruction: What is the total number of # Of Prefectural Votes, when # Of Seats Won is greater than 69, and when Leader is Yasuhiro Nakasone? ### Response:
SELECT COUNT(_number_of_prefectural_votes) FROM table_name_54 WHERE _number_of_seats_won > 69 AND leader = "yasuhiro nakasone"
### Instruction: Show the number of start dates of all the apartment bookings for each year with a bar chart, I want to show Y-axis in asc order please. ### Response:
SELECT booking_start_date, COUNT(booking_start_date) FROM Apartment_Bookings AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id ORDER BY COUNT(booking_start_date)
### Instruction: Which Points have a Visitor of montreal canadiens, and an Attendance larger than 18,568, and a Record of 2 0 1? ### Response:
SELECT MAX("Points") FROM table_50041 WHERE "Visitor" = 'montreal canadiens' AND "Attendance" > '18,568' AND "Record" = '2–0–1'
### Instruction: what is the number of patients whose admission type is emergency and procedure icd9 code is 3512? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND procedures.icd9_code = "3512"
### Instruction: Who was appointed with the title of envoy extraordinary and minister plenipotentiary, and a termination of mission of march 16, 1905? ### Response:
SELECT "Appointed by" FROM table_71304 WHERE "Title" = 'envoy extraordinary and minister plenipotentiary' AND "Termination of Mission" = 'march 16, 1905'
### Instruction: What is the Company Name, when the Accreditation Level is Joyn Hot Fixes, and when the Accreditation Status is Approved (Awarded 17.05.13)? ### Response:
SELECT company_name FROM table_name_13 WHERE accreditation_level = "joyn hot fixes" AND accreditation_status = "approved (awarded 17.05.13)"
### Instruction: is patient 50480 prescribed medication until 1 year ago? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 50480) AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-1 year')
### Instruction: Questions with specific tag below question/answer score. ### Response:
SELECT Q.Id FROM Posts AS Q WHERE Q.PostTypeId = 1 AND Q.Tags LIKE @Pattern AND (Q.Score < @QuestionScore OR (@Accepted = 1 AND Q.AcceptedAnswerId IS NULL) OR NOT EXISTS(SELECT * FROM Posts AS A WHERE A.ParentId = Q.Id AND A.Score >= @AnswerScore))
### Instruction: What is the 1961 total of the Macedonian population with a 1971 number of 3325 and a 1991 value greater than 3177? ### Response:
SELECT COUNT("1961") FROM table_45670 WHERE "Number 1971" = '3325' AND "1991" > '3177'
### Instruction: how did patient 64519 in the last year first visit the hospital? ### Response:
SELECT admissions.admission_type FROM admissions WHERE admissions.subject_id = 64519 AND DATETIME(admissions.admittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY admissions.admittime LIMIT 1
### Instruction: count the number of patients whose admission year is less than 2187 and lab test name is creatinine, urine? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2187" AND lab.label = "Creatinine, Urine"
### Instruction: give me the number of patients whose admission year is less than 2168 and procedure long title is procedure on two vessels? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2168" AND procedures.long_title = "Procedure on two vessels"
### Instruction: give me the number of patients whose admission year is less than 2125 and item id is 51009? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2125" AND lab.itemid = "51009"
### Instruction: Give me the descriptions of the service types that cost more than 100, and count them by a bar chart ### 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
### Instruction: give me the number of patients who have diagnoses icd9 code 5570 and are less than 77 years. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.age < "77" AND diagnoses.icd9_code = "5570"
### Instruction: Top users from Helsinki, Finland. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation FROM Users WHERE LOWER(Location) LIKE '%helsinkiw%' OR UPPER(Location) LIKE '%HELSINKI%' OR Location LIKE '%Helsinki%' AND Reputation >= 1000 ORDER BY Reputation DESC
### Instruction: provide the number of patients who have lab test item id 51447 and were born before the year 1837. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "1837" AND lab.itemid = "51447"
### Instruction: Who is the tuner after season 2004 with Gaurav Gill as the driver, Team MRF, and Mai governing body? ### Response:
SELECT "Tuner" FROM table_56596 WHERE "Season" > '2004' AND "Driver" = 'gaurav gill' AND "Team" = 'team mrf' AND "Governing Body" = 'mai'
### Instruction: how many hours has it been since patient 011-55642 was admitted for to the hospital? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.hospitaladmittime)) FROM patient WHERE patient.uniquepid = '011-55642' AND patient.hospitaldischargetime IS NULL
### Instruction: Calculate the number of patients having exc/des hrt les endovasc and an unspecified death status. ### 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.short_title = "Exc/des hrt les,endovasc"
### Instruction: What is the most noteworthy Bike No that has a Position bigger than 1, and a Points bigger than 369, and an Equipment of zabel-wsp? ### Response:
SELECT MAX("Bike No") FROM table_44226 WHERE "Position" > '1' AND "Points" > '369' AND "Equipment" = 'zabel-wsp'
### Instruction: how many patients with an elective admission type had the drug code morpim? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND prescriptions.formulary_drug_cd = "MORPIM"
### Instruction: For those records from the products and each product's manufacturer, visualize a bar chart about the distribution of founder and the amount of founder , and group by attribute founder, and display in descending by the Founder. ### Response:
SELECT Founder, COUNT(Founder) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder ORDER BY Founder DESC
### Instruction: give me the number of patients whose death status is 0 and diagnoses icd9 code is 5589? ### 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.icd9_code = "5589"
### Instruction: what was the last height of patient 030-75705. ### Response:
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-75705') AND NOT patient.admissionheight IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: What is the 2012 result of a tournament that is 2R in 2007, 1R in 2008 and 1R in 2009? ### Response:
SELECT 2012 FROM table_name_29 WHERE 2009 = "1r" AND 2008 = "1r" AND 2007 = "2r"
### Instruction: what is the number of patients whose death status is 0 and diagnoses long title is atrial fibrillation? ### 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.long_title = "Atrial fibrillation"
### Instruction: tell me the number of patients diagnosed with polymyalgia rheumatica who are less than 81 years. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.age < "81" AND diagnoses.short_title = "Polymyalgia rheumatica"
### Instruction: What year was the 1st Place Team the Hoak Packers, Fresno, CA, and 4th Place was Wells Motors, Greeley, Co? ### Response:
SELECT MAX("Year") FROM table_64333 WHERE "1st Place Team" = 'hoak packers, fresno, ca' AND "4th Place Team" = 'wells motors, greeley, co'