instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: Find all restaurant reviewed by Patrick in ' Los Angeles ### Response:
SELECT business.name FROM business, category, review, user WHERE business.city = 'Los Angeles' AND category.business_id = business.business_id AND category.category_name = 'restaurant' AND review.business_id = business.business_id AND user.name = 'Patrick' AND user.user_id = review.user_id
### Instruction: Questions I have answered without accept (and links). ### Response:
SELECT q.Id AS "post_link", 'https://stackoverflow.com/questions/' + CAST(q.Id AS TEXT) AS "Link", a.CreationDate FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id WHERE a.OwnerUserId = 1531124 AND q.AcceptedAnswerId IS NULL
### Instruction: For those employees who get more salary than the employee whose id is 163, show the frequency of their last name, I want to show total number in desc order. ### Response:
SELECT LAST_NAME, COUNT(LAST_NAME) FROM employees WHERE SALARY > (SELECT SALARY FROM employees WHERE EMPLOYEE_ID = 163) GROUP BY LAST_NAME ORDER BY COUNT(LAST_NAME) DESC
### Instruction: Show the number of apartment bookings for each year and bin booking start date by year interval in a bar chart, and show by the Y in descending. ### 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 ORDER BY COUNT(booking_start_date) DESC
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about the sum of revenue over the name , and group by attribute name, order X-axis from high to low order. ### Response:
SELECT T1.Name, T2.Revenue FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T1.Name ORDER BY T1.Name DESC
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, visualize a scatter chart about the correlation between salary and department_id . ### Response:
SELECT SALARY, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: Which Player has Goals larger than 10, and a Debut year smaller than 1993, and Years at club of 1990 1993? ### Response:
SELECT "Player" FROM table_13443 WHERE "Goals" > '10' AND "Debut year" < '1993' AND "Years at club" = '1990–1993'
### Instruction: Name the Milan San Remo which has a Li ge Bastogne Li ge of danilo di luca ( ita )? ### Response:
SELECT "Milan \u2013 San Remo" FROM table_62552 WHERE "Li\u00e8ge\u2013Bastogne\u2013Li\u00e8ge" = 'danilo di luca ( ita )'
### Instruction: are there any monte carlo simulation papers since 2011 ? ### Response:
SELECT DISTINCT paper.paperid FROM keyphrase, paper, paperkeyphrase WHERE keyphrase.keyphrasename = 'monte carlo simulation' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND paper.year > 2011
### Instruction: what is the number of patients whose lab test chart time is 2150-03-05 06:48:00? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE lab.charttime = "2150-03-05 06:48:00"
### Instruction: how many patients are there with drug code cefe1i who were born before 1846? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dob_year < "1846" AND prescriptions.formulary_drug_cd = "CEFE1I"
### Instruction: What is the lowest wk 7 with a wk 3 value of 12, a wk 4 less than 9, and a wk 2 greater than 11? ### Response:
SELECT MIN("Wk 7") FROM table_42827 WHERE "Wk 3" = '12' AND "Wk 4" < '9' AND "Wk 2" > '11'
### Instruction: fasting serum lipoprotein values of: ldl _ cholesterol, > 160 mg / dl or triglycerides, > 500 mg / dl ### Response:
SELECT * FROM table_dev_40 WHERE fasting_serum_lipoprotein = 1 OR ldl_cholesterol > 160 OR triglyceride_tg > 500
### Instruction: count the number of patients whose primary disease is abdominal pain and procedure short title is suture bladder lacerat? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "ABDOMINAL PAIN" AND procedures.short_title = "Suture bladder lacerat"
### Instruction: Number of unclosed questions with close votes per month. ### Response:
SELECT DATE(MIN(P.CreationDate)) AS PostDay, COUNT(DISTINCT P.Id) FROM Posts AS P INNER JOIN PendingFlags AS PF ON P.Id = PF.PostId WHERE PF.FlagTypeId = 14 GROUP BY YEAR(P.CreationDate), MONTH(P.CreationDate) ORDER BY PostDay
### Instruction: how many patients are admitted before the year 2184 and used the drug fluoxetine hcl? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admityear < "2184" AND prescriptions.drug = "Fluoxetine HCl"
### Instruction: Find the name of physicians who are affiliated with Surgery or Psychiatry department. ### Response:
SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID = T2.physician JOIN department AS T3 ON T2.department = T3.DepartmentID WHERE T3.name = 'Surgery' OR T3.name = 'Psychiatry'
### Instruction: Questions with [tag] closed as duplicate. ### Response:
SELECT YEAR(ClosedDate) AS "year", COUNT(*) AS "questions" FROM Posts LEFT JOIN PostHistory AS PH ON PH.PostId = Posts.Id WHERE STR_POSITION(Tags, @tag) > 0 AND PostTypeId = 1 AND NOT ClosedDate IS NULL AND Comment = '101' GROUP BY YEAR(ClosedDate)
### Instruction: count the number of patients whose admission year is less than 2203 and procedure icd9 code is 3972? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2203" AND procedures.icd9_code = "3972"
### Instruction: Death to 'Belongs on SF'. Comments from migrations into Server Fault about migrating to Server Fault ### Response:
SELECT c.PostId AS "post_link", c.Text AS Commented FROM Comments AS C WHERE C.Text LIKE '%belongs on server fault%' OR C.Text LIKE '%belongs on serverfault%' OR C.Text LIKE '%belongs on sf%' ORDER BY c.CreationDate DESC LIMIT 300
### Instruction: get the number of christian scientist religious background patients who have atrial fibrillation diagnoses. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.religion = "CHRISTIAN SCIENTIST" AND diagnoses.short_title = "Atrial fibrillation"
### Instruction: According to the February 2009 poll by the Corporate Research Associates that reported 31% Liberal., what percentage aligned with the Prog. Cons. party? ### Response:
SELECT "Prog. Cons." FROM table_14048 WHERE "Polling firm" = 'corporate research associates' AND "Liberal" = '31%' AND "Dates" = 'february 2009'
### 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: what number of patients admitted in emergency had drug code enox80i? ### 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.formulary_drug_cd = "ENOX80I"
### 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: For those records from the products and each product's manufacturer, draw a bar chart about the distribution of name and code , and group by attribute founder, sort by the total number from low to high. ### Response:
SELECT T1.Name, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder, T1.Name ORDER BY T1.Code
### Instruction: out of total number of patients who had other postoperative infection, calculate the number of those from jewish belief? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.religion = "JEWISH" AND diagnoses.long_title = "Other postoperative infection"
### 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 years has ELI 380 been taught ? ### Response:
SELECT DISTINCT semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'ELI' AND course.number = 380 AND semester.semester_id = course_offering.semester ORDER BY semester.year LIMIT 1
### Instruction: What is the highest value for Byes, when Wins is less than 16, when Benalla DFL is 'Swanpool', and when Against is less than 2177? ### Response:
SELECT MAX("Byes") FROM table_60206 WHERE "Wins" < '16' AND "Benalla DFL" = 'swanpool' AND "Against" < '2177'
### Instruction: What is the original of the ipa ( rio de janeiro )translation ki mo t a w n t t i t n ? ### Response:
SELECT translation FROM table_23915_4 WHERE ipa___rio_de_janeiro__ = "ki̥ mo̞ɕˈtɾaɾɜ̃w̃ nɐ ˈtɛʁə tɕĩʑiˈtɜ̃nə"
### Instruction: what is the number of patients who stayed in careunit sicu until 4 years ago? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT transfers.hadm_id FROM transfers WHERE transfers.careunit = 'sicu' AND DATETIME(transfers.intime) <= DATETIME(CURRENT_TIME(), '-4 year'))
### Instruction: how many patients whose admission year is less than 2121 and procedure short title is int insert dual-cham dev? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2121" AND procedures.short_title = "Int insert dual-cham dev"
### Instruction: how many patients belonging to black/haitian ethnic background hav ethe procedure icd9 code 8854? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.ethnicity = "BLACK/HAITIAN" AND procedures.icd9_code = "8854"
### Instruction: Find the number of dead patients who had unspecified osteomyelitis and other specified sites diagnoses. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.expire_flag = "1" AND diagnoses.long_title = "Unspecified osteomyelitis, other specified sites"
### Instruction: Show the name and number of employees for the departments managed by heads whose temporary acting value is 'Yes' with a bar chart, show from low to high by the X. ### Response:
SELECT Name, SUM(Num_Employees) FROM department AS T1 JOIN management AS T2 ON T1.department_ID = T2.department_ID WHERE T2.temporary_acting = 'Yes' GROUP BY Name ORDER BY Name
### Instruction: count the number of patients whose admission type is emergency 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.admission_type = "EMERGENCY" AND procedures.short_title = "CV cath plcmt w guidance"
### Instruction: What are the name, id and the corresponding number of visits for each tourist attraction? ### Response:
SELECT T1.name, T2.tourist_attraction_id, COUNT(*) FROM tourist_attractions AS T1 JOIN visits AS T2 ON T1.tourist_attraction_id = T2.tourist_attraction_id GROUP BY T2.tourist_attraction_id
### Instruction: Show the names and genders of players with a coach starting after 2011. ### Response:
SELECT T3.player_name, T3.gender FROM player_coach AS T1 JOIN coach AS T2 ON T1.coach_id = T2.coach_id JOIN player AS T3 ON T1.player_id = T3.player_id WHERE T1.starting_year > 2011
### Instruction: Show the total number of the first year of parties with the theme 'Spring' or 'Teqnology' with a bar chart, bin the first year into weekday interval and count the first year, and I want to display y axis from low to high order. ### Response:
SELECT First_year, COUNT(First_year) FROM party WHERE Party_Theme = "Spring" OR Party_Theme = "Teqnology" ORDER BY COUNT(First_year)
### Instruction: [old] Get a candidate's answers to election questionnaire. See discussion at http://meta.stackexchange.com/q/281666/287315 ### Response:
SELECT Id, link = CONCAT('http://meta.puzzling.stackexchange.com/a/', Id) FROM Posts WHERE ParentId = @questionnaire_question_id AND OwnerUserId = @candidate_user_id
### Instruction: For those records from the products and each product's manufacturer, a bar chart shows the distribution of name and code , and group by attribute founder, and show by the bar from high to low. ### Response:
SELECT T1.Name, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder, T1.Name ORDER BY T1.Name DESC
### Instruction: What is the lowest figure for her age when the year of marriage is before 1853, the number of children is less than 8, and the bride was Eliza Maria Partridge? ### Response:
SELECT MIN("Her Age") FROM table_37536 WHERE "Year of Marriage" < '1853' AND "# of Children" < '8' AND "Name" = 'eliza maria partridge'
### Instruction: What is the score of the floor when the position is less than 21, and less than 81.2 total, and the pommel horse score is 13.925? ### Response:
SELECT "Floor" FROM table_64212 WHERE "Position" < '21' AND "Total" < '81.2' AND "Pommel Horse" = '13.925'
### Instruction: Find New Users Answering Each Other's Questions. ### Response:
SELECT Users.Id, Posts.OwnerUserId FROM Users INNER JOIN Posts ON Users.Id = Posts.OwnerUserId WHERE Users.CreationDate BETWEEN '09/01/2018 00:00:00' AND '09/30/2018 00:00:00'
### Instruction: For those records from the products and each product's manufacturer, return a bar chart about the distribution of name and code , and group by attribute founder, order X-axis from low to high order. ### Response:
SELECT T1.Name, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Founder, T1.Name ORDER BY T1.Name
### Instruction: Who is the leader of the party which has Seats less than 28, a percentage of votes 54.03, and more votes than 120,801? ### Response:
SELECT "Leader" FROM table_52370 WHERE "Seats" < '28' AND "Percentage" = '54.03' AND "Votes" > '120,801'
### Instruction: provide the number of patients whose age is less than 71 and drug code is clin300l? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.age < "71" AND prescriptions.formulary_drug_cd = "CLIN300L"
### Instruction: How many patients born before the year 2043 had a lab test for cerebrospinal fluid (csf)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "2043" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: calculate the number of inputs patient 18757 had. ### Response:
SELECT SUM(inputevents_cv.amount) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 18757))
### Instruction: count the number of patients whose admission type is urgent and procedure short title is percu gastrojejunostomy? ### 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.short_title = "Percu gastrojejunostomy"
### Instruction: Questions filtered by tag, sorted by # of answers. ### Response:
SELECT q.Id AS "post_link", q.CreationDate, q.AnswerCount, q.Score FROM Posts AS q INNER JOIN PostTags AS pt ON q.Id = pt.PostId INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE t.TagName = '##tagName:string##' ORDER BY AnswerCount DESC LIMIT 100
### 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, display 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 > 1000 ORDER BY date_of_transaction DESC
### Instruction: how many patients were admitted to the hospital before the year 2176 and undergone the procedure abdominal wall incision? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2176" AND procedures.short_title = "Abdominal wall incision"
### 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 price , and group by attribute name, sort in desc by the x-axis. ### 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 T2.Name DESC
### Instruction: What was the outcome in the championship where the final score was 6 7(1), 2 6, 6 4, 7 5, 6 7(2)? ### Response:
SELECT outcome FROM table_2362486_1 WHERE score_in_the_final = "6–7(1), 2–6, 6–4, 7–5, 6–7(2)"
### Instruction: calculate the total number of unmarried patients diagnosed with depressive disorder, not elsewhere classified. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.marital_status = "SINGLE" AND diagnoses.long_title = "Depressive disorder, not elsewhere classified"
### Instruction: What is the average number of military deaths when there are fewer than 38 civilian deaths (including foreigners) and 33 military and/or civilian wounded? ### Response:
SELECT AVG(military_deaths) FROM table_name_22 WHERE civilian_deaths__including_foreigners_ < 38 AND military_and_or_civilian_wounded = "33"
### Instruction: count the number of patients whose insurance is medicaid and diagnoses short title is aortocoronary bypass? ### 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.short_title = "Aortocoronary bypass"
### Instruction: look for the procedure icd9 code 3491 of patients who were discharged dead/expired. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "DEAD/EXPIRED" AND procedures.icd9_code = "3491"
### Instruction: let me know the number of patients with procedure icd9 code 3607 who have been hospitalized for more than 27 days. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.days_stay > "27" AND procedures.icd9_code = "3607"
### Instruction: What is AAM Member, when AAM Accredited is No, when State is California, when ASTC Member is Yes, and when City is Sacramento? ### Response:
SELECT "AAM Member" FROM table_42125 WHERE "AAM Accredited" = 'no' AND "State" = 'california' AND "ASTC Member" = 'yes' AND "City" = 'sacramento'
### Instruction: give 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: Show the number of courses each instructor taught in a stacked bar chart. The x-axis is the instructor's first name and group by course code. ### Response:
SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM GROUP BY CRS_CODE, EMP_FNAME
### Instruction: Which Inhabitants has a Party of south tyrolean people's party, a Municipality of bruneck, and an Election larger than 2010? ### Response:
SELECT AVG("Inhabitants") FROM table_8160 WHERE "Party" = 'south tyrolean people''s party' AND "Municipality" = 'bruneck' AND "Election" > '2010'
### Instruction: Name the Runs has a Venue of bellerive oval , hobart, and a Season of 2004/05, and a Rank of 5? ### Response:
SELECT "Runs" FROM table_8606 WHERE "Venue" = 'bellerive oval , hobart' AND "Season" = '2004/05' AND "Rank" = '5'
### Instruction: where is GENERAL MITCHELL INTERNATIONAL located ### Response:
SELECT DISTINCT city.city_code FROM airport, airport_service, city WHERE airport.airport_code = airport_service.airport_code AND airport.airport_name LIKE 'GENERAL MITCHELL INTERNATIONAL' AND city.city_code = airport_service.city_code
### Instruction: Unsolved high quality ID questions. ### Response:
SELECT p.Id, Score, Title, 'http://movies.stackexchange.com/questions/' + CAST(p.Id AS TEXT(10)) AS link, CreationDate FROM Posts AS p WHERE DeletionDate IS NULL AND ClosedDate IS NULL AND Tags LIKE '%identify%' AND AcceptedAnswerId IS NULL AND Score > 2 ORDER BY Score DESC
### 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 the number of patients whose admission type is emergency and procedure long title is diagnostic ultrasound of heart? ### 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 = "Diagnostic ultrasound of heart"
### 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: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about employee_id over the email . ### Response:
SELECT EMAIL, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### 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: how many patients below 68 years had the procedure long title venous catheterization for renal dialysis? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.age < "68" AND procedures.long_title = "Venous catheterization for renal dialysis"
### 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: What was the lowest population of the GEO ID 3805373380 and the water square mileage smaller than 5.729? ### Response:
SELECT MIN("Pop. (2010)") FROM table_62963 WHERE "GEO ID" = '3805373380' AND "Water (sqmi)" < '5.729'
### Instruction: Find Alice's friends of friends. ### Response:
SELECT DISTINCT T4.name FROM PersonFriend AS T1 JOIN Person AS T2 ON T1.name = T2.name JOIN PersonFriend AS T3 ON T1.friend = T3.name JOIN PersonFriend AS T4 ON T3.friend = T4.name WHERE T2.name = 'Alice' AND T4.name <> 'Alice'