instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: what was the last id of patient 20441's ward? ### Response:
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20441) AND NOT transfers.wardid IS NULL ORDER BY transfers.intime DESC LIMIT 1
### Instruction: what is the number of medicare patients who had clofarabine intravenous infusion? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.insurance = "Medicare" AND procedures.short_title = "IV infusion clofarabine"
### Instruction: count the number of patients whose insurance is private and procedure short title is spinal canal explor nec? ### 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.short_title = "Spinal canal explor NEC"
### Instruction: Give me a stacked bar chart to show how many things in different types of each thing, and the details of the organization that owns it. ### Response:
SELECT organization_details, COUNT(organization_details) FROM Things AS T1 JOIN Organizations AS T2 ON T1.organization_id = T2.organization_id GROUP BY Type_of_Thing_Code, organization_details
### Instruction: What are the titles and ids for albums containing tracks with unit price greater than 1, and show in descending by the total number please. ### Response:
SELECT T1.Title, T1.AlbumId FROM Album AS T1 JOIN Track AS T2 ON T1.AlbumId = T2.AlbumId WHERE T2.UnitPrice > 1 ORDER BY T1.AlbumId DESC
### Instruction: What is the last name of the professor whose office is located in DRE 102, and when were they hired? ### Response:
SELECT T1.emp_lname, T1.emp_hiredate FROM employee AS T1 JOIN professor AS T2 ON T1.emp_num = T2.emp_num WHERE T2.prof_office = 'DRE 102'
### Instruction: Find the sum of credits of courses that have more than one prerequisites for each department with a bar chart, order Y from low to high order. ### Response:
SELECT dept_name, SUM(credits) FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY dept_name ORDER BY SUM(credits)
### Instruction: What is the Tie no of the Carlisle United Away game on 17/11/1990 with a Score of 5 0? ### Response:
SELECT tie_no FROM table_name_27 WHERE date = "17/11/1990" AND score = "5–0" AND away_team = "carlisle united"
### Instruction: How many points were there in a year earlier than 1977, a Cosworth V8 engine, and an entry from HB Bewaking alarm systems? ### Response:
SELECT "Points" FROM table_57589 WHERE "Year" < '1977' AND "Engine" = 'cosworth v8' AND "Entrant" = 'hb bewaking alarm systems'
### Instruction: what is the number of patients whose admission type is urgent and lab test name is phenytoin? ### 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 = "Phenytoin"
### Instruction: What was the average number of members Nominated by the Taoiseach, when the Agricultural Panel had less than 1 member, and when the Administrative Panel had fewer than 0 members? ### Response:
SELECT AVG(nominated_by_the_taoiseach) FROM table_name_10 WHERE agricultural_panel < 1 AND administrative_panel < 0
### Instruction: how many patients whose admission type is elective and procedure long title is arthrocentesis? ### 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 = "Arthrocentesis"
### Instruction: Show all cities where at least one customer lives in but no performer lives in. ### Response:
SELECT T1.city_town FROM addresses AS T1 JOIN customers AS T2 ON T1.address_id = T2.address_id EXCEPT SELECT T1.city_town FROM addresses AS T1 JOIN performers AS T2 ON T1.address_id = T2.address_id
### Instruction: Get all tags, which appear in posts with a specific tag. ### Response:
WITH TaggedPosts(PostId) AS (SELECT PostId FROM PostTags AS pt WHERE pt.TagId = @t_id) SELECT DISTINCT TagId FROM TaggedPosts AS tpos JOIN PostTags AS pt ON pt.PostId = tpos.PostId WHERE pt.TagId != @t_id
### Instruction: provide the number of patients younger than 30 years who have procedure icd9 code 3771. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.age < "30" AND procedures.icd9_code = "3771"
### Instruction: Which coding entry has a 3'utr sequence of 1a 0 and a 5'utr splice that is abd? ### Response:
SELECT "Coding" FROM table_41751 WHERE "3\u2019UTR sequence" = '1a 0' AND "5\u2019UTR splice" = 'abd'
### Instruction: Show the names of journalists and the number of events they reported. Visualize by bar chart. ### Response:
SELECT T3.Name, COUNT(*) FROM news_report AS T1 JOIN event AS T2 ON T1.Event_ID = T2.Event_ID JOIN journalist AS T3 ON T1.journalist_ID = T3.journalist_ID GROUP BY T3.Name
### Instruction: Name the total number of EBIT (US $m) in 2011 and a Earnings per share ( ) larger than 47? ### Response:
SELECT COUNT("EBIT (US $m)") FROM table_60286 WHERE "Year to April" = '2011' AND "Earnings per share (\u00a2)" > '47'
### Instruction: A bar chart about how many different professors are there for the different schools?, and list y axis from high to low order. ### Response:
SELECT SCHOOL_CODE, COUNT(*) FROM DEPARTMENT AS T1 JOIN PROFESSOR AS T2 ON T1.DEPT_CODE = T2.DEPT_CODE GROUP BY T1.SCHOOL_CODE ORDER BY COUNT(*) DESC
### Instruction: What is HDTV, when Content is Cinema, when Package/Option is Sky Cinema + Sky HD, and when Television Service is Sky Cinema Passion HD? ### Response:
SELECT "HDTV" FROM table_7184 WHERE "Content" = 'cinema' AND "Package/Option" = 'sky cinema + sky hd' AND "Television service" = 'sky cinema passion hd'
### Instruction: provide the number of patients whose marital status is single and item id is 50911? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.marital_status = "SINGLE" AND lab.itemid = "50911"
### Instruction: how many elective hospital admission patients are diagnosed with blood in stool? ### 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.long_title = "Blood in stool"
### Instruction: List the dates of enrollment and completion of the student with personal name 'Karson'. ### Response:
SELECT T1.date_of_enrolment, T1.date_of_completion FROM student_course_enrolment AS T1 JOIN students AS T2 ON T1.student_id = T2.student_id WHERE T2.personal_name = "Karson"
### Instruction: what is the number of patients whose ethnicity is asian and drug type is base? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "ASIAN" AND prescriptions.drug_type = "BASE"
### Instruction: how many patients whose insurance is self pay and diagnoses short title is dermatitis nos? ### 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.short_title = "Dermatitis NOS"
### Instruction: For all employees who have the letters D or S in their first name, a bar chart shows the distribution of job_id and the sum of department_id , and group by attribute job_id. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID
### Instruction: Which Reactortype has a gross capacity of 417 mw and an Electricity Grid of 27.12.1971? ### Response:
SELECT "Reactortype" FROM table_70001 WHERE "Gross capacity" = '417 mw' AND "Electricity Grid" = '27.12.1971'
### Instruction: How many patients are with medicaid insurance and procedured for other radiotherapeutic? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.insurance = "Medicaid" AND procedures.long_title = "Other radiotherapeutic procedure"
### Instruction: What is the result of the league/cup competition with the swindon wildcats as the opponent and neil liddiard as the man of the match? ### Response:
SELECT result FROM table_name_45 WHERE competition = "league/cup" AND opponent = "swindon wildcats" AND man_of_the_match = "neil liddiard"
### Instruction: When the score in the final is 3 6, 6 4, 3 6, 4 6, who are all the opponents in the final? ### Response:
SELECT "Opponent in the final" FROM table_73920 WHERE "Score in the final" = '3–6, 6–4, 3–6, 4–6'
### Instruction: How many are on the administrative panel with an agricultural panel of fewer than 11 and an industrial and commercial panel of 3, with fewer than 4 on the labor panel? ### Response:
SELECT AVG(administrative_panel) FROM table_name_7 WHERE agricultural_panel < 11 AND industrial_and_commercial_panel = 3 AND labour_panel < 4
### Instruction: count the number of patients whose admission type is emergency 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.admission_type = "EMERGENCY" AND prescriptions.route = "IH"
### Instruction: Most close votes by off topic reason. By Santa Claus. I don't do much SQL, but it works. Occasionally you will find a recently closed question in there. Off-topic choices: http://data.stackexchange.com/stackoverflow/revision/216660/283083/off-topic-reasons ### Response:
SELECT * FROM ReviewTaskStates
### Instruction: What are the job titles, and range of salaries for jobs with maximum salary between 12000 and 18000. Plot them as bar chart. ### Response:
SELECT JOB_TITLE, MAX_SALARY - MIN_SALARY FROM jobs WHERE MAX_SALARY BETWEEN 12000 AND 18000
### Instruction: Show me a bar chart for what are the different affiliations, and what is the total enrollment of schools founded after 1850 for each enrollment type?, and show by the y axis in descending. ### Response:
SELECT Affiliation, SUM(Enrollment) FROM university WHERE Founded > 1850 GROUP BY Affiliation ORDER BY SUM(Enrollment) DESC
### Instruction: Find the number of patients who were diagnosed with tobacco use disorder and survived ### 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 = "Tobacco use disorder"
### Instruction: What is the Chassis having a year later than 1990, and Minardi Scuderia Italia as an entrant, and 4 points? ### Response:
SELECT "Chassis" FROM table_11934 WHERE "Year" > '1990' AND "Entrant" = 'minardi scuderia italia' AND "Points" = '4'
### Instruction: What is Yearly Cost For Paid Account, when Montly Cost For Paid Account is 5 USD, and when Userpics Paid is 50? ### Response:
SELECT "Yearly Cost for Paid Account" FROM table_47186 WHERE "Monthly Cost for Paid Account" = '5 usd' AND "Userpics Paid" = '50'
### Instruction: What is the number for the University of Dublin with their Cultural and Educational Panel of 5, and an Industrial and Commercial Panel with less than 9? ### Response:
SELECT COUNT(university_of_dublin) FROM table_name_46 WHERE cultural_and_educational_panel = 5 AND industrial_and_commercial_panel < 9
### Instruction: Count the number of patients admitted before 2124 categorized under chemistry lab tests. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2124" AND lab."CATEGORY" = "Chemistry"
### Instruction: Display a bar chart for what is the name of each course and the corresponding number of student enrollment?, could you display by the y axis in asc? ### Response:
SELECT course_name, COUNT(*) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY COUNT(*)
### Instruction: When is the earliest year with a Torque of 330n m (243lb ft) @ 2000-2500? ### Response:
SELECT MIN("Year") FROM table_69442 WHERE "Torque" = '330n·m (243lb·ft) @ 2000-2500'
### Instruction: Which Condition has a Bleeding time of prolonged, a Platelet count of decreased, and Prothrombin time of prolonged? ### Response:
SELECT "Condition" FROM table_42607 WHERE "Bleeding time" = 'prolonged' AND "Platelet count" = 'decreased' AND "Prothrombin time" = 'prolonged'
### Instruction: Show the number of courses each instructor taught in a bar chart, rank X-axis in asc order. ### Response:
SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM GROUP BY EMP_FNAME ORDER BY EMP_FNAME
### Instruction: There are communities listed that a percentage larger than 7.6 in 2001, but none of them has 2 seats listed in 2006. ### Response:
SELECT SUM("Seats 2001") FROM table_11295 WHERE "Seats 2006" = '2' AND "% 2001" > '7.6'
### Instruction: Who is the visitor team on Saturday, November 22 when link pings hc was the home team and there were more than 20 rounds? ### Response:
SELECT "Visitor" FROM table_62911 WHERE "Home" = 'linköpings hc' AND "Round" > '20' AND "Date" = 'saturday, november 22'
### Instruction: Check title, body, tags for a certain word. ### Response:
SELECT p.CreationDate, p.Body, p.Id AS "post_link" FROM Posts AS p WHERE p.PostTypeId = 1 AND p.Body LIKE '%##keyword1##%' OR p.Title LIKE '%##keyword1##%' OR p.Tags LIKE '%##keyword1##%' LIMIT 100
### Instruction: How many Campeonato Paulistas had a campeonato brasileiro of more than 2, an others number of more than 0, and a copa sudamericana of more than 5? ### Response:
SELECT COUNT(campeonato_paulista) FROM table_name_72 WHERE campeonato_brasileiro > 2 AND others > 0 AND copa_sudamericana > 5
### Instruction: What are the polling dates for polling firm Holinshed when Terry Kilrea dropped out and Bob Chiarelli has 22.5%? ### Response:
SELECT "Terry Kilrea (dropped out)" FROM table_58622 WHERE "Polling Firm" = 'holinshed' AND "Bob Chiarelli" = '22.5%'
### Instruction: let me know the short title of both procedure and diagnoses for patient lue white. ### Response:
SELECT diagnoses.short_title, procedures.short_title FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.name = "Lue White"
### Instruction: give the number of patients who passed away in or before the year 2154 had femoral artery thrombosis. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "FEMORAL ARTERY THROMBOSIS" AND demographic.dod_year <= "2154.0"
### Instruction: Past bounties by bounty date. ### Response:
SELECT PostId AS "post_link", * FROM Votes WHERE VoteTypeId = 9 AND CreationDate BETWEEN '07/01/2020' AND '09/30/2020' AND BountyAmount > 0 ORDER BY CreationDate, BountyAmount DESC
### Instruction: how many patients whose age is less than 64 and procedure icd9 code is 3891? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.age < "64" AND procedures.icd9_code = "3891"
### Instruction: Who was the 1999-2002 Years for Grizzlies small forward Player who was from the United States? ### Response:
SELECT "Player" FROM table_44821 WHERE "Nationality" = 'united states' AND "Position" = 'small forward' AND "Years for Grizzlies" = '1999-2002'
### Instruction: For each party, return the name of the party and the number of delegates from that party Plot them as bar chart, rank by the bars in desc. ### Response:
SELECT T2.Party, SUM(COUNT(*)) FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID GROUP BY T2.Party ORDER BY T2.Party DESC
### Instruction: most popular tags with avarage score >=2. ### Response:
SELECT Tags.TagName, COUNT(*) AS "Number of Questions" FROM Posts, PostTags, Tags WHERE Posts.Id = PostTags.PostId AND PostTags.TagId = Tags.Id GROUP BY Tags.TagName HAVING AVG(Posts.Score + 0.0) >= 2 ORDER BY COUNT(*) DESC
### Instruction: Provide the number of white ethnic background patients for whom a total protein body fluid lab test has been ordered. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.ethnicity = "WHITE" AND lab.label = "Total Protein, Body Fluid"
### Instruction: how many patients who died were procedured for implant of pulsation balloon? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.expire_flag = "1" AND procedures.long_title = "Implant of pulsation balloon"
### Instruction: What is the average Played, when Goals Against is less than 63, when Team is 'Nelson', and when Lost is greater than 16? ### Response:
SELECT AVG("Played") FROM table_60988 WHERE "Goals Against" < '63' AND "Team" = 'nelson' AND "Lost" > '16'
### Instruction: how many private insurance patients have diagnoses icd9 code 58089? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.insurance = "Private" AND diagnoses.icd9_code = "58089"
### Instruction: What's the longitude for philae sulcus in 1997 with a diameter less than 1,575.0? ### Response:
SELECT "Longitude" FROM table_50432 WHERE "Diameter" < '1,575.0' AND "Year named" = '1997' AND "Name" = 'philae sulcus'
### Instruction: For those records from the products and each product's manufacturer, show me about the distribution of headquarter and the sum of revenue , and group by attribute headquarter in a bar chart. ### Response:
SELECT Headquarter, SUM(Revenue) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter
### Instruction: What is High Assists, when High Points is 'Kobe Bryant (27)', and when High Rebounds is 'Pau Gasol (11)'? ### Response:
SELECT "High assists" FROM table_77378 WHERE "High points" = 'kobe bryant (27)' AND "High rebounds" = 'pau gasol (11)'
### Instruction: List users from by location. ### Response:
SELECT DisplayName AS Name, ('http://stackoverflow.com/users/' + CAST(Id AS TEXT) + '/' + REPLACE(LOWER(DisplayName), ' ', '-')) AS URI, Reputation, Views FROM Users WHERE LOWER(Location) LIKE '%' + LOWER(@Location) + '%' ORDER BY Reputation DESC
### Instruction: how many patients treated with citalopram remained admitted in hospital for more than a day? ### 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 = "Citalopram"
### Instruction: Get Most Viewed For Tag. ### Response:
SELECT * FROM (SELECT p.*, ViewCount / DATEDIFF(dd, CreationDate, GETUTCDATE()) AS ViewRate FROM Tags AS t JOIN PostTags AS pt ON t.Id = pt.TagId JOIN Posts AS p ON pt.PostId = p.Id WHERE t.TagName = 'microsoftgraph') AS tmp ORDER BY ViewRate DESC
### Instruction: What is the total of against matches when there are less than 12 wins, less than 0 draws, and Moulamein is the golden river? ### Response:
SELECT SUM("Against") FROM table_59645 WHERE "Wins" < '12' AND "Golden Rivers" = 'moulamein' AND "Draws" < '0'
### Instruction: What is the Copa Libertadores 1999 result for team vasco, which made the group stage in the Copa Mercosur 1999? ### Response:
SELECT "Copa Libertadores 1999" FROM table_39175 WHERE "Copa Mercosur 1999" = 'group stage' AND "Team" = 'vasco'
### Instruction: Which departments have the top 3 highest number of students? Show the department address and number of students with a pie chart. ### Response:
SELECT DEPT_ADDRESS, COUNT(*) FROM STUDENT AS T1 JOIN DEPARTMENT AS T2 ON T1.DEPT_CODE = T2.DEPT_CODE GROUP BY T1.DEPT_CODE ORDER BY COUNT(*) DESC LIMIT 3
### Instruction: Visualize a bar chart for how many assets can each parts be used in? List the part name and the number, and display X in descending order. ### Response:
SELECT part_name, COUNT(*) FROM Parts AS T1 JOIN Asset_Parts AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name ORDER BY part_name DESC
### Instruction: when did patient 65569 come in 2105 for the last time to the hospital? ### Response:
SELECT admissions.admittime FROM admissions WHERE admissions.subject_id = 65569 AND STRFTIME('%y', admissions.admittime) = '2105' ORDER BY admissions.admittime DESC LIMIT 1
### Instruction: How much 2005 has a 2006 larger than 4,67, and a 2004 of -14,76? ### Response:
SELECT COUNT("2005") FROM table_60236 WHERE "2006" > '4,67' AND "2004" = '-14,76'
### Instruction: calculate the total number of private patients diagnosed with schizoaffective dis nos. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.insurance = "Private" AND diagnoses.short_title = "Schizoaffective dis NOS"
### Instruction: A line chart for what are the number of the dates in which the mean sea level pressure was between 303 and 31?, and I want to display date from low to high order. ### Response:
SELECT date, COUNT(date) FROM weather WHERE mean_sea_level_pressure_inches BETWEEN 30.3 AND 31 GROUP BY date ORDER BY date
### Instruction: Which classes are ULCS classes ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, program, program_course WHERE program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND program.name LIKE '%CS-LSA%' AND program.program_id = program_course.program_id
### Instruction: Which Village has a Region of C te De Nuits, Wine Styles of Red Wine, and a Grand Cru of Latrici res-Chambertin? ### Response:
SELECT village FROM table_name_57 WHERE region = "côte de nuits" AND wine_style = "red wine" AND grand_cru = "latricières-chambertin"
### Instruction: If the velocity angle is ln[(1 + 5)/2] 0.481, what is the condition/parameter? ### Response:
SELECT condition_parameter FROM table_15314901_1 WHERE velocity_angle_η_in_i_radians = "ln[(1 + √5)/2] ≅ 0.481"
### Instruction: Name the first elected for hosea moffitt (f) 57.9% josiah masters (dr) 42.1% ### Response:
SELECT "First elected" FROM table_74004 WHERE "Candidates" = 'Hosea Moffitt (F) 57.9% Josiah Masters (DR) 42.1%'
### Instruction: out of total number of patients who had a lab test for joint fluid, calulate the number of those aged below 68 ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.age < "68" AND lab.fluid = "Joint Fluid"
### Instruction: What murder (2012) rate per 100,00 also has a 1.616 as the peace (2012) GPI? ### Response:
SELECT murder__2012__rate_per_100, 000 FROM table_name_26 WHERE peace__2012__gpi = 1.616
### Instruction: Calculate the number of patients admitted to emergency who had an ld body fluid test by lab ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND lab.label = "LD, Body Fluid"
### Instruction: what number of patients admitted in urgent care had their route mentioned as ivpca? ### 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.route = "IVPCA"
### Instruction: What is the population when the Per capita income of $18,884, and a Number of households smaller than 14,485? ### Response:
SELECT SUM(population) FROM table_name_98 WHERE per_capita_income = "$18,884" AND number_of_households < 14 OFFSET 485
### Instruction: provide the number of patients whose insurance is medicare and diagnoses short title is bacteremia? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.insurance = "Medicare" AND diagnoses.short_title = "Bacteremia"
### Instruction: count the number of patients whose insurance is private and procedure icd9 code is 4610? ### 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.icd9_code = "4610"
### Instruction: What is the most points 1 when the goals against are fewer than 97, lost less than 22, 9 draws and goal difference of +28? ### Response:
SELECT MAX(points_1) FROM table_name_57 WHERE goals_against < 97 AND lost < 22 AND drawn = 9 AND goal_difference = "+28"
### Instruction: how many patients whose admission type is urgent and drug route is po/ng? ### 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.route = "PO/NG"
### Instruction: Who Votes to Close, Reopen, Delete, Undelete the Most?. ### Response:
SELECT v.* FROM Users AS u INNER JOIN Votes AS v ON u.Id = v.UserId WHERE u.Id = '##UserId:int##' AND v.VoteTypeId IN (6, 7, 10, 11) ORDER BY v.VoteTypeId
### Instruction: what is the number of patients whose age is less than 89 and item id is 50953? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.age < "89" AND lab.itemid = "50953"
### Instruction: How many patients are admitted as new born and discharged to disc-tran cancer/chldrn h? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_type = "NEWBORN" AND demographic.discharge_location = "DISC-TRAN CANCER/CHLDRN H"
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about price over the name , and group by attribute headquarter by a bar chart. ### Response:
SELECT T1.Name, T1.Price FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter, T1.Name
### Instruction: A bar chart about how many students are enrolled in colleges that have student accepted during tryouts, and in which states are those colleges?, and display in ascending by the x-axis. ### Response:
SELECT state, enr FROM College AS T1 JOIN Tryout AS T2 ON T1.cName = T2.cName WHERE T2.decision = 'yes' ORDER BY state
### Instruction: What is the lowest week number that there was a game on October 23, 1977 with less than 68,977 people attending? ### Response:
SELECT MIN("Week") FROM table_35791 WHERE "Attendance" < '68,977' AND "Date" = 'october 23, 1977'
### Instruction: what was the result of the next game after the date of january 15 , 1954 ? ### Response:
SELECT "result" FROM table_204_329 WHERE "date" > (SELECT "date" FROM table_204_329 WHERE "date" = '15 january 1954') ORDER BY "date" LIMIT 1
### Instruction: give me the number of patients of white ethnicity diagnosed for retained plastic fragments. ### 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 = "Retain plastic fragments"
### Instruction: What is the average sales in billions of the company headquartered in France with more than 2,539.1 billion in assets? ### Response:
SELECT AVG("Sales (billion $)") FROM table_45129 WHERE "Headquarters" = 'france' AND "Assets (billion $)" > '2,539.1'
### Instruction: What was the average election year that has less than 136 deputies, and 1,560,753 votes received? ### Response:
SELECT AVG(election_date) FROM table_name_86 WHERE number_of_deputies < 136 AND number_of_votes_received = "1,560,753"
### Instruction: how many patients whose insurance is government and procedure short title is heart countershock nec? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.insurance = "Government" AND procedures.short_title = "Heart countershock NEC"
### Instruction: provide the number of patients whose insurance is private and procedure icd9 code is 8968? ### 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.icd9_code = "8968"
### Instruction: how many patients whose admission location is phys referral/normal deli and admission year is less than 2176? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND demographic.admityear < "2176"