instruction
stringlengths 53
549
| output
stringlengths 30
2.33k
|
---|---|
### Instruction:
what is the number of patients whose year of death is less than or equal to 2115 and item id is 50824?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dod_year <= "2115.0" AND lab.itemid = "50824" |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, draw a scatter chart about the correlation between salary and commission_pct .
### Response:
| SELECT SALARY, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) |
### Instruction:
For all employees who have the letters D or S in their first name, visualize a bar chart about the distribution of hire_date and the average of salary bin hire_date by time, sort by the Y from low to high.
### Response:
| SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(SALARY) |
### Instruction:
How many years has ENSCEN 475 been offered ?
### Response:
| SELECT DISTINCT semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'ENSCEN' AND course.number = 475 AND semester.semester_id = course_offering.semester ORDER BY semester.year LIMIT 1 |
### Instruction:
For those employees who was hired before 2002-06-21, give me the comparison about the average of salary over the hire_date bin hire_date by time, and show y axis in asc order.
### Response:
| SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(SALARY) |
### Instruction:
what is the number of patients whose year of death is less than or equal to 2183 and item id is 51351?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dod_year <= "2183.0" AND lab.itemid = "51351" |
### Instruction:
For those records from the products and each product's manufacturer, give me the comparison about the sum of price over the name , and group by attribute name by a bar chart, and order y-axis in descending order.
### Response:
| SELECT T2.Name, T1.Price FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Name ORDER BY T1.Price DESC |
### Instruction:
Show the number of documents created in each day and bin document date by year interval and group by document type description with a group line chart, I want to rank x axis in descending order.
### Response:
| SELECT Document_Date, COUNT(Document_Date) FROM Ref_Document_Types AS T1 JOIN Documents AS T2 ON T1.Document_Type_Code = T2.Document_Type_Code GROUP BY Document_Type_Description ORDER BY Document_Date DESC |
### Instruction:
how many patients are discharged to snf and followed the procedure combined right and left cardiac catheterization?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "SNF" AND procedures.long_title = "Combined right and left heart cardiac catheterization" |
### Instruction:
how many patients admitted via physician referral/normal delivery have sertraline prescription?
### 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.drug = "Sertraline" |
### Instruction:
What is the money list rank when the starts are less than 30, earnings are larger than 8,689, and the ranking is 2 in the top 25?
### Response:
| SELECT "Money list rank" FROM table_41650 WHERE "Starts" < '30' AND "Earnings (\u20ac)" > '8,689' AND "Top 25" = '2' |
### Instruction:
For those records from the products and each product's manufacturer, return a bar chart about the distribution of name and manufacturer , and group by attribute founder, and could you sort by the bar in asc?
### 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.Name |
### Instruction:
what is the number of patients whose admission type is urgent and lab test name is asparate aminotransferase (ast)?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admission_type = "URGENT" AND lab.label = "Asparate Aminotransferase (AST)" |
### 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:
give me the number of patients whose days of hospital stay is greater than 1 and drug code is meth40?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.days_stay > "1" AND prescriptions.formulary_drug_cd = "METH40" |
### 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:
number of hospital visits of patient 011-53628 in this year.
### Response:
| SELECT COUNT(DISTINCT patient.patienthealthsystemstayid) FROM patient WHERE patient.uniquepid = '011-53628' AND DATETIME(patient.hospitaladmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') |
### Instruction:
give me the number of elective hospital admission patients who had cardiopulmonary resuscitation, 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 = "ELECTIVE" AND procedures.long_title = "Cardiopulmonary resuscitation, not otherwise specified" |
### Instruction:
Give me a bar chart that group and count names of technicians with a series of machines they are assigned to repair, sort X from high to low order.
### Response:
| SELECT Name, COUNT(Name) FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.Machine_ID = T2.Machine_ID JOIN technician AS T3 ON T1.technician_id = T3.technician_id GROUP BY Name ORDER BY Name DESC |
### 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:
For those records from the products and each product's manufacturer, a bar chart shows the distribution of founder and the average of code , and group by attribute founder, rank from low to high by the Founder.
### 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 T2.Founder |
### Instruction:
count the number of patients whose marital status is widowed and diagnoses short title is systolic hrt failure nos?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.marital_status = "WIDOWED" AND diagnoses.short_title = "Systolic hrt failure NOS" |
### Instruction:
what is the number of patients whose primary disease is gastrointestinal bleed and procedure icd9 code is 14?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "GASTROINTESTINAL BLEED" AND procedures.icd9_code = "14" |
### Instruction:
How many games in total did team Boston Red Stockings attend from 2000 to 2010?
### Response:
| SELECT SUM(T1.attendance) FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' AND T1.year BETWEEN 2000 AND 2010 |
### Instruction:
Which Name has a Years Played of 2004 2008, and a Date and Opponent of 2/17/07 vs. purdue?
### Response:
| SELECT "Name" FROM table_48077 WHERE "Years Played" = '2004–2008' AND "Date and Opponent" = '2/17/07 vs. purdue' |
### Instruction:
colombia has the highest graduate enrollment at 15,760 . what school has the next highest ?
### Response:
| SELECT "institution" FROM table_203_592 WHERE "graduate enrollment" < (SELECT "graduate enrollment" FROM table_203_592 WHERE "institution" = 'columbia university') ORDER BY "graduate enrollment" DESC LIMIT 1 |
### Instruction:
what is the number of patients whose marital status is married and diagnoses icd9 code is 25541?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.marital_status = "MARRIED" AND diagnoses.icd9_code = "25541" |
### Instruction:
Use a bar chart to show the number of start dates of all the apartment bookings made by guests with gender code 'Female' for each weekday.
### Response:
| SELECT booking_start_date, COUNT(booking_start_date) FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id = T2.guest_id WHERE T2.gender_code = "Female" |
### Instruction:
tell me the number of black/cape verdean ethnic background patients for whom direct bilirubin lab test was ordered.
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.ethnicity = "BLACK/CAPE VERDEAN" AND lab.label = "Bilirubin, Direct" |
### Instruction:
For those employees who did not have any job in the past, give me the comparison about the sum of salary over the hire_date bin hire_date by weekday, and rank sum salary in ascending order.
### Response:
| SELECT HIRE_DATE, SUM(SALARY) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY SUM(SALARY) |
### Instruction:
For those records from the products and each product's manufacturer, find name and price , and group by attribute founder, and visualize them by a bar chart, and sort by the Y from low to high.
### Response:
| SELECT T1.Name, T1.Price FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder, T1.Name ORDER BY T1.Price |
### Instruction:
since 2101 what was patient 006-193056's last hospital discharge time?
### Response:
| SELECT patient.hospitaldischargetime FROM patient WHERE patient.uniquepid = '006-193056' AND STRFTIME('%y', patient.hospitaldischargetime) >= '2101' ORDER BY patient.hospitaldischargetime DESC LIMIT 1 |
### Instruction:
For those records from the products and each product's manufacturer, visualize a bar chart about the distribution of founder and the sum of code , and group by attribute founder, and order Y in desc 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 DESC |
### Instruction:
Does post length reduce score?.
### Response:
| SELECT LENGTH(Body) / @line_length, AVG(CAST(Score AS FLOAT)) FROM Posts WHERE Score > 1 AND ViewCount > 0 AND LENGTH(Body) BETWEEN 1 AND 1500 GROUP BY LENGTH(Body) / @line_length ORDER BY LENGTH(Body) / @line_length |
### Instruction:
get the number of patients who had biopsy of tonsil and adenoids and were admitted before 2138.
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2138" AND procedures.short_title = "Tonsil&adenoid biopsy" |
### Instruction:
Find the names and publication dates of all catalogs that have catalog level number greater than 5. Bin publication dates into Year interval, and count catalog and group by catalog name.
### Response:
| SELECT date_of_publication, COUNT(date_of_publication) FROM Catalogs AS t1 JOIN Catalog_Structure AS t2 ON t1.catalog_id = t2.catalog_id WHERE catalog_level_number > 5 GROUP BY catalog_name |
### Instruction:
Collect the list of patients with a chart time of 2151-12-28 15:30:00 on lab test.
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE lab.charttime = "2151-12-28 15:30:00" |
### Instruction:
give me the number of patients whose insurance is private and procedure long title is parenteral infusion of concentrated nutritional substances?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.insurance = "Private" AND procedures.long_title = "Parenteral infusion of concentrated nutritional substances" |
### Instruction:
give me the number of patients whose year of birth is less than 1821 and drug name is nystatin cream?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dob_year < "1821" AND prescriptions.drug = "Nystatin Cream" |
### Instruction:
give me the number of emergency hospital admission patients who had initial insertion of tranvenous lead [electrode] into ventricle.
### 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.short_title = "Int insert lead in vent" |
### Instruction:
get me the number of patients with lab test item id 51025 who died in the year 2126 or before that.
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dod_year <= "2126.0" AND lab.itemid = "51025" |
### Instruction:
count the number of patients whose ethnicity is white and drug name is neo*iv*gentamicin?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "WHITE" AND prescriptions.drug = "NEO*IV*Gentamicin" |
### Instruction:
what is the number of patients whose year of birth is less than 2110 and diagnoses short title is dehydration?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dob_year < "2110" AND diagnoses.short_title = "Dehydration" |
### Instruction:
What are the names and average prices of products for manufacturers whose products cost on average 150 or more Plot them as bar chart, sort total number in descending order.
### Response:
| SELECT T2.Name, AVG(T1.Price) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Name ORDER BY AVG(T1.Price) DESC |
### Instruction:
Are there any ULCS courses in the courses I 've taken ?
### Response:
| SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN student_record ON student_record.course_id = course.course_id INNER JOIN program_course ON student_record.course_id = program_course.course_id WHERE program_course.category LIKE '%ULCS%' AND student_record.student_id = 1 |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about salary over the phone_number by a bar chart.
### Response:
| SELECT PHONE_NUMBER, SALARY FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) |
### Instruction:
top authors working on ImageNet ?
### Response:
| SELECT DISTINCT COUNT(paper.paperid), writes.paperid FROM dataset, paper, paperdataset, writes WHERE dataset.datasetname = 'ImageNet' AND paperdataset.datasetid = dataset.datasetid AND paper.paperid = paperdataset.paperid AND writes.paperid = paper.paperid GROUP BY writes.paperid ORDER BY COUNT(paper.paperid) DESC |
### Instruction:
total cholesterol < 205 , triglycerides < 250 , or low density lipoprotein ( ldl ) < 130
### Response:
| SELECT * FROM table_train_176 WHERE total_cholesterol < 205 OR triglyceride_tg < 250 OR low_density_lipoprotein_ldl_cholesterol < 130 |
### Instruction:
What is the proportion of each customer's move in date? You can show me a bar chart that bins move in date into Year interval, and sort by the y axis in ascending.
### Response:
| SELECT date_moved_in, COUNT(date_moved_in) FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id = T2.customer_id ORDER BY COUNT(date_moved_in) |
### Instruction:
Compare the number of chips from different company names for the phone whose screen mode type is 'Graphics' with a bar chart, could you order by the X from high to low?
### Response:
| SELECT Company_name, COUNT(Company_name) FROM screen_mode AS T1 JOIN phone AS T2 ON T1.Graphics_mode = T2.screen_mode WHERE T1.Type = "Graphics" GROUP BY Company_name ORDER BY Company_name DESC |
### Instruction:
provide the number of patients whose days of hospital stay is greater than 4 and diagnoses icd9 code is 99681?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.days_stay > "4" AND diagnoses.icd9_code = "99681" |
### Instruction:
open questions with 'possible duplicate of ... unix.stackexchange' comment. questions that aren't closed but have comments with the phrase 'possible duplicate of
### Response:
| SELECT Comments.Text, Posts.Id AS "post_link", Posts.* FROM Posts JOIN Comments ON Comments.PostId = Posts.Id WHERE Comments.Text LIKE 'possible duplicate of %unix.stackexchange.com/questions/%' AND Posts.ClosedDate IS NULL |
### Instruction:
find the name and age of the pilot who has won the most number of times among the pilots who are younger than 30.
### Response:
| SELECT t1.name, t1.age FROM pilot AS t1 JOIN match AS t2 ON t1.pilot_id = t2.winning_pilot WHERE t1.age < 30 GROUP BY t2.winning_pilot ORDER BY COUNT(*) DESC LIMIT 1 |
### Instruction:
what is the number of patients whose ethnicity is hispanic or latino and item id is 51104?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.ethnicity = "HISPANIC OR LATINO" AND lab.itemid = "51104" |
### Instruction:
What is the % Of Constituency Vote, when # Of Constituency Votes is greater than 25,643,309, and when # Of Candidates is 310?
### Response:
| SELECT "% of Constituency vote" FROM table_50554 WHERE "# of Constituency votes" > '25,643,309' AND "# of candidates" = '310' |
### Instruction:
python tagged q&a score >= 50.
### Response:
| SELECT q.Id, q.Title, q.Body, q.Tags, q.Score, q.AcceptedAnswerId, a.Body AS answerbody FROM Posts AS q INNER JOIN Posts AS a ON a.Id = q.AcceptedAnswerId WHERE q.PostTypeId = 1 AND q.Score >= 50 AND q.Tags LIKE '%<python>%' |
### Instruction:
How much tonnage has a Fate of sunk, and a Flag of great britain, and a Date of 26 september 1940, and Deaths of 2?
### Response:
| SELECT SUM(tonnage___grt__) FROM table_name_83 WHERE fate = "sunk" AND flag = "great britain" AND date = "26 september 1940" AND deaths = 2 |
### 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 number of patients whose ethnicity is hispanic/latino - puerto rican and year of birth is less than 2071?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND demographic.dob_year < "2071" |
### 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:
have any prescriptions been given since 5 years ago to patient 25951?
### Response:
| SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25951) AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-5 year') |
### 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:
what is maximum age of patients whose discharge location is home and primary disease is st-segment elevation myocardial infarction\cardiac cath?
### Response:
| SELECT MAX(demographic.age) FROM demographic WHERE demographic.discharge_location = "HOME" AND demographic.diagnosis = "ST-SEGMENT ELEVATION MYOCARDIAL INFARCTION\CARDIAC CATH" |
### Instruction:
What is Show, when Episode Number is 1, when Year is less than 2010, and when Original Airdate is January 20, 2008?
### Response:
| SELECT "Show" FROM table_46368 WHERE "Episode number" = '1' AND "Year" < '2010' AND "Original airdate" = 'january 20, 2008' |
### Instruction:
What's the Elevator that has Elevated: 1378, September 18, an Order of Cardinal-Priest, and an Elector of Poncello Orsini?
### Response:
| SELECT elevator FROM table_name_25 WHERE elevated = "1378, september 18" AND order = "cardinal-priest" AND elector = "poncello orsini" |
### Instruction:
What is the result on Sunday that's somav r on Monday and mangalav r on Tuesday?
### Response:
| SELECT "Sunday Surya (the Sun)" FROM table_14415 WHERE "Monday Soma (the Moon)" = 'सोमवार somavār' AND "Tuesday Mangala (Mars)" = 'मंगलवार mangalavār' |
### Instruction:
For those records from the products and each product's manufacturer, find name and the sum of code , and group by attribute name, and visualize them by a bar chart, and rank by the x axis in asc.
### Response:
| SELECT T2.Name, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Name ORDER BY T2.Name |
### Instruction:
how many patients diagnosed with esophageal reflux were discharged to home health care?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.discharge_location = "HOME HEALTH CARE" AND diagnoses.long_title = "Esophageal reflux" |
### Instruction:
evidence of clinically relevant and uncontrolled hypertensive, cardiac, pulmonary, vascular, metabolic or hematologic conditions.
### Response:
| SELECT * FROM table_train_133 WHERE hypertension = 1 OR cardiac = 1 OR pulmonary_disease = 1 OR vascular = 1 OR metabolic = 1 OR hematologic_disease = 1 |
### Instruction:
what were the three most frequent lab tests until 3 years ago?
### Response:
| SELECT t1.labname FROM (SELECT lab.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM lab WHERE DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 3 |
### Instruction:
how many patients whose age is less than 44 and drug name is 0.9% sodium chloride?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.age < "44" AND prescriptions.drug = "0.9% Sodium Chloride" |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, a scatter chart shows the correlation between employee_id and salary .
### Response:
| SELECT EMPLOYEE_ID, SALARY FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) |
### Instruction:
What is the first name and GPA of every student that has a GPA lower than average Show bar chart, and could you display by the y axis in desc?
### Response:
| SELECT STU_FNAME, SUM(STU_GPA) FROM STUDENT WHERE STU_GPA < (SELECT AVG(STU_GPA) FROM STUDENT) GROUP BY STU_FNAME ORDER BY SUM(STU_GPA) DESC |
### Instruction:
Among patients to whom drug was administered in both eyes, how many of them were born before the year 2170.
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dob_year < "2170" AND prescriptions.route = "BOTH EYES" |
### Instruction:
At what location did the event that used electric traction and system name ATM (1880 1911) GETA (1911 1944) occur?
### Response:
| SELECT location FROM table_name_5 WHERE name_of_system = "atm (1880–1911) geta (1911–1944)" AND traction_type = "electric" |
### Instruction:
count the number of patients whose days of hospital stay is greater than 1 and diagnoses icd9 code is e8791?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.days_stay > "1" AND diagnoses.icd9_code = "E8791" |
### Instruction:
provide the number of patients whose admission type is urgent and drug code is amid200?
### 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.formulary_drug_cd = "AMID200" |
### Instruction:
Tables with a given collection of columns.
### Response:
| WITH FindColumns AS (SELECT 'Id' AS Seek UNION SELECT 'PostId' AS Seek), MyTables AS (SELECT object_id AS Tab, COUNT(*) AS ColCount FROM sys.columns INNER JOIN FindColumns ON name = Seek GROUP BY object_id) SELECT * FROM sys.tables INNER JOIN MyTables ON object_id = Tab WHERE ColCount = (SELECT COUNT(*) FROM FindColumns) |
Subsets and Splits