instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: provide the number of patients whose language is span and procedure long title is incision of vessel, abdominal arteries? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.language = "SPAN" AND procedures.long_title = "Incision of vessel, abdominal arteries"
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about the sum of price over the founder , and group by attribute founder by a bar chart, show y-axis in descending order. ### Response:
SELECT Founder, SUM(Price) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder ORDER BY SUM(Price) DESC
### Instruction: how much is patient 89875's hospital bill for his or her stay since 2103? ### Response:
SELECT SUM(cost.cost) FROM cost WHERE cost.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 89875) AND STRFTIME('%y', cost.chargetime) >= '2103'
### Instruction: WHAT WAS THE HOME TEAM'S SCORE WHEN THEY HAD A CROWD GREATER THAN 20,000 AND PLAYED AGAINST COLLINGWOOD? ### Response:
SELECT "Home team score" FROM table_33336 WHERE "Crowd" > '20,000' AND "Away team" = 'collingwood'
### Instruction: give me the number of patients whose diagnoses long title is acute on chronic combined systolic and diastolic heart failure? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE diagnoses.long_title = "Acute on chronic combined systolic and diastolic heart failure"
### Instruction: when has patient 029-8147 visited the hospital for the first time until 4 years ago? ### Response:
SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '029-8147' AND DATETIME(patient.hospitaladmittime) <= DATETIME(CURRENT_TIME(), '-4 year') ORDER BY patient.hospitaladmittime LIMIT 1
### Instruction: provide the number of patients whose discharge location is home and procedure short title is cardiopulm resuscita nos? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "HOME" AND procedures.short_title = "Cardiopulm resuscita NOS"
### Instruction: give me the number of patients whose admission year is less than 2114 and item id is 50806? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2114" AND lab.itemid = "50806"
### Instruction: For those records from the products and each product's manufacturer, draw a bar chart about the distribution of name and the average of code , and group by attribute name, and display in asc by the Y. ### 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 T1.Code
### Instruction: What is every entry for Saturday August 27 when the entry for Thursday August 25 is 23' 56.90 94.528mph? ### Response:
SELECT sat_27_aug FROM table_30058355_7 WHERE thurs_25_aug = "23' 56.90 94.528mph"
### Instruction: let me know the number of patients less than 48 years who had diagnoses icd9 code 56210. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.age < "48" AND diagnoses.icd9_code = "56210"
### Instruction: give me the number of patients whose ethnicity is white - russian and drug route is ivpca? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "WHITE - RUSSIAN" AND prescriptions.route = "IVPCA"
### Instruction: For those records from the products and each product's manufacturer, a bar chart shows the distribution of name and the sum of code , and group by attribute name, sort total number of code in asc order. ### 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 T1.Code
### Instruction: A bar chart for what are the number of the dates of transactions with at least 100 share count or amount bigger than 100?, I want to display Y-axis in ascending order. ### Response:
SELECT date_of_transaction, COUNT(date_of_transaction) FROM Transactions WHERE share_count >= 100 OR amount_of_transaction >= 100 ORDER BY COUNT(date_of_transaction)
### Instruction: Top SO users from Arizona. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation, Location FROM Users WHERE Reputation >= (SELECT Reputation FROM Users WHERE Id = 5285908) AND (UPPER(Location) LIKE '% AZ%' OR UPPER(Location) LIKE '% ARIZONA%') ORDER BY Reputation DESC
### Instruction: Which Label has a Country of united kingdom, a Date of 22 september 2008, and a Catalogue number(s) of eredv711? ### Response:
SELECT "Label" FROM table_60539 WHERE "Country" = 'united kingdom' AND "Date" = '22 september 2008' AND "Catalogue number(s)" = 'eredv711'
### Instruction: What is the name of the customer that made the order with the largest quantity? ### Response:
SELECT 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 WHERE t3.order_quantity = (SELECT MAX(order_quantity) FROM order_items)
### Instruction: Who is the main contestant with a total score/week of 42/60 and a co-contestant (Yaar vs. Pyaa) of Tina Sachdev? ### Response:
SELECT main_contestant FROM table_name_29 WHERE total_score_week = "42/60" AND co_contestant__yaar_vs_pyaar_ = "tina sachdev"
### Instruction: Find duplicate of a specific post. ### Response:
SELECT PostLinks.PostId AS "post_link" FROM PostLinks WHERE PostLinks.LinkTypeId = 3 AND NOT (SELECT Posts.Id FROM Posts WHERE Posts.Id = PostLinks.PostId AND Posts.OwnerUserId = '##UderId##') IS NULL GROUP BY PostLinks.PostId ORDER BY PostLinks.PostId
### Instruction: Open questions with the Possible Duplicate bit. ### Response:
SELECT Score, Id AS "post_link", ViewCount, OwnerUserId AS "user_link", CreationDate FROM Posts WHERE PostTypeId = 1 AND ClosedDate IS NULL AND (Body LIKE '%<strong>Possible Duplicate:</strong>%' OR Body LIKE '%<strong>Possible Duplicates:</strong>%') ORDER BY CreationDate
### Instruction: Total Population (2011 est) larger than 30,262,610, and a Hindu total of 63,718 involves what country? ### Response:
SELECT "Country" FROM table_75570 WHERE "Total Population (2011 est)" > '30,262,610' AND "Hindu total" = '63,718'
### 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 whose admission year is less than 2138 and procedure icd9 code is 966? ### 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.icd9_code = "966"
### 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: provide the number of patients whose admission location is emergency room admit and lab test name is hemoglobin? ### 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.label = "Hemoglobin"
### 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 are the number of the titles of all movies that have between 3 and 5 stars?, and could you sort the number of title from high to low order? ### Response:
SELECT title, COUNT(title) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE T1.stars BETWEEN 3 AND 5 GROUP BY title ORDER BY COUNT(title) DESC
### 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: how many patients stayed in hospital for more than 34 days and were procedured with icd9 code 3931? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.days_stay > "34" AND procedures.icd9_code = "3931"
### 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 2007 value with 1r in 2009 and 2r in 2011 at the Tournament of Wimbledon? ### Response:
SELECT "2007" FROM table_68652 WHERE "2009" = '1r' AND "2011" = '2r' AND "Tournament" = 'wimbledon'
### Instruction: provide the number of patients whose marital status is single and procedure short title is cv cath plcmt w guidance? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.marital_status = "SINGLE" AND procedures.short_title = "CV cath plcmt w guidance"
### 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: What is the polyunsaturated fat with a smoke point of c (), a total fat of 100g and 63g of monounsaturated fat? ### Response:
SELECT polyunsaturated_fat FROM table_name_28 WHERE smoke_point = "°c ()" AND total_fat = "100g" AND monounsaturated_fat = "63g"
### Instruction: give the number of patients whose diagnosis long title is acute on chronic combined systolic and diastolic heart failure. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE diagnoses.long_title = "Acute on chronic combined systolic and diastolic heart failure"
### Instruction: count the number of patients who had urgent hospital admission along with one vascular stent insertion procedure. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "URGENT" AND procedures.long_title = "Insertion of one vascular stent"
### Instruction: what is the margin of victory when the runner-up is amy alcott and the winning score is 9 (72-68-67=207)? ### Response:
SELECT "Margin of victory" FROM table_77252 WHERE "Runner(s)-up" = 'amy alcott' AND "Winning score" = '–9 (72-68-67=207)'
### Instruction: Show all train names and times in stations in London in descending order by train time. ### Response:
SELECT T3.name, T3.time FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id JOIN train AS T3 ON T3.train_id = T1.train_id WHERE T2.location = 'London' ORDER BY T3.time DESC
### Instruction: Which are the top 10 commodities that have the highest residue during 2015? ### Response:
SELECT T2.commod FROM resultsdata15 AS T2 JOIN sampledata15 AS T1 ON T1.sample_pk = T2.sample_pk WHERE T1.year = 15 GROUP BY T2.commod ORDER BY SUM(T2.concen) DESC LIMIT 10
### Instruction: What is the 2007 value with a 4r in 2006, a 1r in 2004, and a 4r in 2009? ### Response:
SELECT 2007 FROM table_name_48 WHERE 2006 = "4r" AND 2004 = "1r" AND 2009 = "4r"
### Instruction: find the number of patients born before the year 2058 whose procedure icd9 code is 3782. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dob_year < "2058" AND procedures.icd9_code = "3782"
### Instruction: what is the number of patients whose admission year is less than 2155 and lab test name is homocysteine? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2155" AND lab.label = "Homocysteine"
### Instruction: Name the score in the final for runner-up and hard surface with opponents being micha l llodra nenad zimonji ### Response:
SELECT "Score in the final" FROM table_69333 WHERE "Outcome" = 'runner-up' AND "Surface" = 'hard' AND "Opponents in the final" = 'michaël llodra nenad zimonjić'
### Instruction: provide the number of patients whose admission year is less than 2139 and item id is 50893? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2139" AND lab.itemid = "50893"
### Instruction: Which SR number had a wheel arrangement of 0-6-0t, the year made was more recent than 1874, and the year withdrawn was 1963? ### Response:
SELECT sr_no FROM table_name_87 WHERE wheel_arrangement = "0-6-0t" AND year_made > 1874 AND year_withdrawn = 1963
### Instruction: Which workshop groups have bookings with status code 'stop'? Give me the names, and count them by a bar chart ### Response:
SELECT Store_Name, COUNT(Store_Name) FROM Bookings AS T1 JOIN Drama_Workshop_Groups AS T2 ON T1.Workshop_Group_ID = T2.Workshop_Group_ID WHERE T1.Status_Code = "stop" GROUP BY Store_Name
### Instruction: count the number of hospital visits made to patient 035-11731 since 5 years ago. ### Response:
SELECT COUNT(DISTINCT patient.patienthealthsystemstayid) FROM patient WHERE patient.uniquepid = '035-11731' AND DATETIME(patient.hospitaladmittime) >= DATETIME(CURRENT_TIME(), '-5 year')
### Instruction: Votes: DownVote to UpVote Ratio. ### Response:
SELECT Id AS "user_link", Reputation, UpVotes, DownVotes, ROUND(CAST(UpVotes AS FLOAT) / DownVotes, 1) AS Ratio FROM Users WHERE Reputation > 100 AND UpVotes > 0 AND DownVotes > 0 ORDER BY Ratio DESC LIMIT 50
### Instruction: How many bookings did each customer make? List the first name as the X-axis, and the count as the Y-axis in the bar chart, could you order by the total number in descending please? ### Response:
SELECT first_name, COUNT(*) FROM Customers AS T1 JOIN Bookings AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY COUNT(*) DESC
### Instruction: how many patients have stayed at the ward 45 since 3 years ago? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT transfers.hadm_id FROM transfers WHERE transfers.wardid = 45 AND DATETIME(transfers.intime) >= DATETIME(CURRENT_TIME(), '-3 year'))
### Instruction: Get posts count time series by the tag. ### Response:
SELECT DATEFROMPARTS(YEAR(P.CreationDate), MONTH(P.CreationDate), 1) AS PostMonth, COUNT(*) AS TagCount FROM Posts AS P WHERE PostTypeId = 1 AND P.Tags LIKE @TagName GROUP BY YEAR(P.CreationDate), MONTH(P.CreationDate) ORDER BY PostMonth
### Instruction: how many patients whose admission type is emergency and diagnoses long title is morbid obesity? ### 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 = "Morbid obesity"
### Instruction: provide the number of patients whose admission year is less than 2173 and drug route is buccal? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admityear < "2173" AND prescriptions.route = "BUCCAL"
### Instruction: what is the number of black/haitian ethnic background patients who take drug via po/ng route? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "BLACK/HAITIAN" AND prescriptions.route = "PO/NG"
### Instruction: How many patients who had open biopsy of liver were discharged to home health care? ### 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.long_title = "Open biopsy of liver"
### Instruction: What is the average prom (m) when the height (m) is more than 733, the class is Hewitt, and the peak is Kirk Fell East Top? ### Response:
SELECT AVG("Prom. (m)") FROM table_12033 WHERE "Height (m)" > '733' AND "Class" = 'hewitt' AND "Peak" = 'kirk fell east top'
### Instruction: what is the number of patients whose year of birth is less than 2053 and item id is 51383? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "2053" AND lab.itemid = "51383"
### Instruction: Top 100 Answers for a User. ### Response:
SELECT Other.Title AS "Question Title", Other.Body AS "Question Body", Answers.Body AS "Answer" FROM Posts AS Answers INNER JOIN Posts AS Other ON Answers.ParentId = Other.Id WHERE Answers.OwnerUserId = @UserId AND Answers.ParentId != 0 ORDER BY Answers.Score DESC LIMIT 100
### Instruction: Count the number of patients who were prescribed a base drug type and stayed in the hospital for more than 11 days. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.days_stay > "11" AND prescriptions.drug_type = "BASE"
### Instruction: how many of the patients admitted as transfer from hosp/extram had icd9 code 45? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND procedures.icd9_code = "45"
### Instruction: Top Users by Number of Bounty Points. ### Response:
SELECT Posts.OwnerUserId AS "user_link", COUNT(*) AS BountiesWon, SUM(Votes.BountyAmount) AS Booty FROM Votes INNER JOIN Posts ON Votes.PostId = Posts.Id WHERE VoteTypeId = 9 GROUP BY Posts.OwnerUserId ORDER BY Booty DESC LIMIT 100
### Instruction: For those records from the products and each product's manufacturer, return a bar chart about the distribution of name and the sum of code , and group by attribute name, list Y in desc order. ### Response:
SELECT T1.Name, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T1.Name ORDER BY T1.Code DESC
### Instruction: What is the highest Market Value (billion $), when Rank is 02 2, and when Sales (billion $) is greater than 113.1? ### Response:
SELECT MAX("Market Value (billion $)") FROM table_49281 WHERE "Rank" = '02 2' AND "Sales (billion $)" > '113.1'
### Instruction: how many patients have stayed in the hospital for more than 3 days with a drug name phenylephrine? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.days_stay > "3" AND prescriptions.drug = "PHENYLEPHrine"
### Instruction: For each film, return the number of cinemas showing that fim in a bar chart, could you rank by the Title in asc? ### Response:
SELECT Title, COUNT(Title) 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 Title ORDER BY Title
### Instruction: For Posts Created in 2017, Avg time between Question created and Accepted Ans. ### Response:
SELECT CreationDate FROM PostFeedback WHERE CAST(CreationDate AS DATETIME) BETWEEN '2017-01-01 00:00:00' AND '2017-12-31 23:59:59'
### Instruction: provide the number of patients whose admission year is less than 2166 and item id is 50885? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2166" AND lab.itemid = "50885"
### Instruction: how many prescribed drugs were prescribed to patient 32160 in 2105? ### Response:
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 32160) AND STRFTIME('%y', prescriptions.startdate) = '2105'
### Instruction: provide the number of patients whose admission year is less than 2139 and item id is 51276? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2139" AND lab.itemid = "51276"
### Instruction: what is the number of patients with procedure icd9 code 8968 who were born before 2114? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dob_year < "2114" AND procedures.icd9_code = "8968"
### Instruction: provide the number of patients whose marital status is divorced and lab test name is protein/creatinine ratio? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.marital_status = "DIVORCED" AND lab.label = "Protein/Creatinine Ratio"
### Instruction: How many games tied for the team with over 94 years in the conference, lost under 5,297 games, and a percentage higher than 0.6106? ### Response:
SELECT "Tied" FROM table_52330 WHERE "Years" > '94' AND "Lost" < '5,297' AND "Pct." > '0.6106'
### Instruction: Find the number of students who is older than 20 in each dorm. ### Response:
SELECT COUNT(*), T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name
### Instruction: Who was the SS when jim lefebvre was at 2nd, willie davis at CF, and don drysdale was the SP. ### Response:
SELECT "Shortstop" FROM table_72289 WHERE "Second Baseman" = 'Jim Lefebvre' AND "Centerfielder" = 'Willie Davis' AND "Starting Pitcher" = 'Don Drysdale'
### Instruction: What was the Sat 21 Aug time for the driver whose Thurs 26 Aug time was 20' 56.01 108.143mph? ### Response:
SELECT "Sat 21 Aug" FROM table_29203 WHERE "Thurs 26 Aug" = '20'' 56.01 108.143mph'
### Instruction: Show the names of all the activities Mark Giuliano participates in. ### Response:
SELECT T3.activity_name FROM faculty AS T1 JOIN faculty_participates_in AS T2 ON T1.facid = T2.facid JOIN activity AS T3 ON T3.actid = T2.actid WHERE T1.fname = "Mark" AND T1.lname = "Giuliano"
### Instruction: What is the highest Loss, when Long is greater than 0, when Gain is greater than 484, and when Avg/g is greater than 126.4? ### Response:
SELECT MAX("Loss") FROM table_76633 WHERE "Long" > '0' AND "Gain" > '484' AND "Avg/g" > '126.4'
### 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'
### Instruction: What was the average year that the Nashville Metros did not qualify for the Playoffs, did not qualify for the Open Cup, and had the Regular Season 7th, Southeast? ### Response:
SELECT AVG(year) FROM table_name_78 WHERE playoffs = "did not qualify" AND open_cup = "did not qualify" AND regular_season = "7th, southeast"
### Instruction: since 1 year ago patient 013-33898 had been in an er? ### Response:
SELECT COUNT(*) > 0 FROM patient WHERE patient.uniquepid = '013-33898' AND patient.hospitaladmitsource = 'emergency department' AND DATETIME(patient.unitadmittime) >= DATETIME(CURRENT_TIME(), '-1 year')
### Instruction: How many years did barclay nordica arrows bmw enter with a bmw str-4 t/c engine with less than 1 point? ### Response:
SELECT SUM("Year") FROM table_70405 WHERE "Engine" = 'bmw str-4 t/c' AND "Entrant" = 'barclay nordica arrows bmw' AND "Points" < '1'
### Instruction: how many party with candidates being john m. vorys (r) 61.5% jacob f. myers (d) 38.5% ### Response:
SELECT COUNT("Party") FROM table_18486 WHERE "Candidates" = 'John M. Vorys (R) 61.5% Jacob F. Myers (D) 38.5%'
### Instruction: how many patients born before the year 2060 were given the cephalexin? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dob_year < "2060" AND prescriptions.drug = "Cephalexin"
### Instruction: count the number of patients whose age is less than 64 and drug code is warf1? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.age < "64" AND prescriptions.formulary_drug_cd = "WARF1"
### Instruction: What position does the Wales player who made more than 167 appearances, had more than 0 goals, and had a Leeds career from 1977 1982 play? ### Response:
SELECT position FROM table_name_56 WHERE appearances > 167 AND nationality = "wales" AND goals > 0 AND leeds_career = "1977–1982"
### Instruction: For those employees who was hired before 2002-06-21, draw a line chart about the change of salary over hire_date , and show from high to low by the HIRE_DATE. ### Response:
SELECT HIRE_DATE, SALARY FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY HIRE_DATE DESC
### Instruction: how many white patients had the diagnosis short title hyperlipidemia nec/nos? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "WHITE" AND diagnoses.short_title = "Hyperlipidemia NEC/NOS"
### Instruction: give me the number of medicaid patients who have diagnoses icd9 code 99659. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.insurance = "Medicaid" AND diagnoses.icd9_code = "99659"
### Instruction: who is the NBA team for the draft year after 2003 with a height of 6'10' and home town of st. charles, mo? ### Response:
SELECT "NBA Team" FROM table_70626 WHERE "Draft Year" > '2003' AND "Height" = '6''10' AND "Hometown" = 'st. charles, mo'
### Instruction: A line chart for what are the number of the dates of transactions with at least 100 share count or amount bigger than 100?, and sort from high to low by the X-axis. ### Response:
SELECT date_of_transaction, COUNT(date_of_transaction) FROM Transactions WHERE share_count >= 100 OR amount_of_transaction >= 100 ORDER BY date_of_transaction DESC
### Instruction: provide the number of patients whose year of birth is less than 1821 and drug route is left eye? ### 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.route = "LEFT EYE"
### Instruction: WHAT IS THE ORICON PEAK NUMBER WITH AN ATLANTIC LABEL, SUBHUMAN RACE, LATER THAN 1995? ### Response:
SELECT COUNT("Oricon peak") FROM table_48368 WHERE "Label" = 'atlantic' AND "Title" = 'subhuman race' AND "Date of release" > '1995'