table
stringlengths
33
7.14k
question
stringlengths
4
1.06k
output
stringlengths
2
4.44k
⌀
CREATE TABLE cinema ( cinema_id number, name text, openning_year number, capacity number, location text ) CREATE TABLE schedule ( cinema_id number, film_id number, date text, show_times_per_day number, price number ) CREATE TABLE film ( film_id number, rank_in_series nu...
Show the cinema name and location for cinemas with capacity above average.
SELECT name, location FROM cinema WHERE capacity > (SELECT AVG(capacity) FROM cinema)
CREATE TABLE gas_station ( Station_ID int, Open_Year int, Location text, Manager_Name text, Vice_Manager_Name text, Representative_Name text ) CREATE TABLE station_company ( Station_ID int, Company_ID int, Rank_of_the_Year int ) CREATE TABLE company ( Company_ID int, Rank i...
List all headquarters and the number of companies in each headquarter with a bar chart, show from low to high by the Headquarters.
SELECT Headquarters, COUNT(*) FROM company GROUP BY Headquarters ORDER BY Headquarters
CREATE TABLE table_65773 ( "Voting order" real, "Country" text, "Spokespersons" text, "Commentator" text, "Broadcaster" text )
What was the voting order when bunny carr was the commentator?
SELECT SUM("Voting order") FROM table_65773 WHERE "Commentator" = 'bunny carr'
CREATE TABLE follows ( f1 number, f2 number ) CREATE TABLE tweets ( id number, uid number, text text, createdate time ) CREATE TABLE user_profiles ( uid number, name text, email text, partitionid number, followers number )
Find the number of followers for each user.
SELECT COUNT(*) FROM follows GROUP BY f1
CREATE TABLE table_203_660 ( id number, "county" text, "obama%" text, "obama#" number, "mccain%" text, "mccain#" number, "total" number )
what was the total listed for camden county ?
SELECT "total" FROM table_203_660 WHERE "county" = 'camden'
CREATE TABLE PostNoticeTypes ( Id number, ClassId number, Name text, Body text, IsHidden boolean, Predefined boolean, PostNoticeDurationId number ) CREATE TABLE Comments ( Id number, PostId number, Score number, Text text, CreationDate time, UserDisplayName text, ...
Select users by 'About Me' ordered by reputation.
SELECT u.Id AS "user_link", u.Location AS "location", u.LastAccessDate AS "last_access", u.WebsiteUrl AS "url", u.Reputation AS "rep", u.AboutMe AS AboutMe FROM Users AS u WHERE LOWER(AboutMe) LIKE '##aboutme:string##' ORDER BY Reputation DESC LIMIT 300
CREATE TABLE table_73868 ( "Constituency" text, "Candidate" text, "Affiliation" text, "Result - votes" real, "Result - %" text, "Loss/gain" text )
What is every affiliation for the Tottenham constituency?
SELECT "Affiliation" FROM table_73868 WHERE "Constituency" = 'Tottenham'
CREATE TABLE table_name_74 ( elimination VARCHAR, time VARCHAR )
What is the elimination number for the time 13:43?
SELECT elimination FROM table_name_74 WHERE time = "13:43"
CREATE TABLE table_47073 ( "Nat." text, "Name" text, "Moving from" text, "Type" text, "Transfer window" text, "Ends" real, "Transfer fee" text )
What is Moving From, when Ends is before 2011?
SELECT "Moving from" FROM table_47073 WHERE "Ends" < '2011'
CREATE TABLE table_27268238_5 ( team VARCHAR, economy VARCHAR )
What is the team when the economy is 5.73?
SELECT team FROM table_27268238_5 WHERE economy = "5.73"
CREATE TABLE microbiologyevents ( row_id number, subject_id number, hadm_id number, charttime time, spec_type_desc text, org_name text ) CREATE TABLE d_icd_procedures ( row_id number, icd9_code text, short_title text, long_title text ) CREATE TABLE transfers ( row_id number...
what was the name of the first intake that patient 19175 had on last month/03.
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT inputevents_cv.itemid 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 = 19175)) AND DATETIME(inputevents_cv....
CREATE TABLE table_30688 ( "No. in series" real, "No. in season" real, "Title" text, "Directed by" text, "Written by" text, "Original air date" text, "U.S. viewers (million)" text )
How many people directed 'a little death'?
SELECT COUNT("Directed by") FROM table_30688 WHERE "Title" = 'A Little Death'
CREATE TABLE film ( Film_ID int, Rank_in_series int, Number_in_season int, Title text, Directed_by text, Original_air_date text, Production_code text ) CREATE TABLE cinema ( Cinema_ID int, Name text, Openning_year int, Capacity int, Location text ) CREATE TABLE schedule...
Show each location and the number of cinemas there Show bar chart, could you order in ascending by the Y-axis?
SELECT Location, COUNT(*) FROM cinema GROUP BY Location ORDER BY COUNT(*)
CREATE TABLE table_28366 ( "No. in series" real, "Title" text, "Directed by" text, "Written by" text, "Original air date" text, "Production code" real )
What was the original air date of 'kiss the girls and make them die'?
SELECT "Original air date" FROM table_28366 WHERE "Title" = 'Kiss the Girls and Make Them Die'
CREATE TABLE table_name_89 ( opponent VARCHAR, score VARCHAR )
Which opponent has a Score of 15.4.94?
SELECT opponent FROM table_name_89 WHERE score = "15.4.94"
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location t...
specify the total number of patients who had icd9 code 4105
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE procedures.icd9_code = "4105"
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id...
what is ethnicity of subject name jerry deberry?
SELECT demographic.ethnicity FROM demographic WHERE demographic.name = "Jerry Deberry"
CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(...
For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of hire_date and the average of department_id bin hire_date by time in a bar chart, list in ascending by the y axis.
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY AVG(DEPARTMENT_ID)
CREATE TABLE ReviewTaskTypes ( Id number, Name text, Description text ) CREATE TABLE VoteTypes ( Id number, Name text ) CREATE TABLE PostTags ( PostId number, TagId number ) CREATE TABLE PostTypes ( Id number, Name text ) CREATE TABLE PostFeedback ( Id number, PostId numb...
Select random non-closed, non-cw answers. Enter Query Description
SELECT LENGTH(Body) AS body_len, Score FROM Posts WHERE CommunityOwnedDate IS NULL AND ClosedDate IS NULL AND PostTypeId = 2 ORDER BY NEWID() LIMIT 1000
CREATE TABLE table_name_71 ( females VARCHAR, language VARCHAR )
What females speak Romanian?
SELECT females FROM table_name_71 WHERE language = "romanian"
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location t...
which type of drug is colchicine?
SELECT prescriptions.drug_type FROM prescriptions WHERE prescriptions.drug = "Colchicine"
CREATE TABLE patient ( uniquepid text, patienthealthsystemstayid number, patientunitstayid number, gender text, age text, ethnicity text, hospitalid number, wardid number, admissionheight number, admissionweight number, dischargeweight number, hospitaladmittime time, ...
how much did patient 010-17316 spend for their hospital stay since 2105?
SELECT SUM(cost.cost) FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-17316') AND STRFTIME('%y', cost.chargetime) >= '2105'
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic (...
what is the total number of patients who had arthrocentesis?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE procedures.long_title = "Arthrocentesis"
CREATE TABLE icustays ( row_id number, subject_id number, hadm_id number, icustay_id number, first_careunit text, last_careunit text, first_wardid number, last_wardid number, intime time, outtime time ) CREATE TABLE d_labitems ( row_id number, itemid number, label te...
tell me the insurance plan for patient 9619 when they came to the hospital last time?
SELECT admissions.insurance FROM admissions WHERE admissions.subject_id = 9619 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1
CREATE TABLE table_13836704_4 ( total_passengers_2008 INTEGER, change_2008_09 VARCHAR )
what being the maximum total passengers 2008 with change 2008/09 being 6.5%
SELECT MAX(total_passengers_2008) FROM table_13836704_4 WHERE change_2008_09 = "6.5%"
CREATE TABLE program_course ( program_id int, course_id int, workload int, category varchar ) CREATE TABLE offering_instructor ( offering_instructor_id int, offering_id int, instructor_id int ) CREATE TABLE program_requirement ( program_id int, category varchar, min_credit int,...
Which upper level CS courses are offered this following semester ?
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN program_course ON program_course.course_id = course.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE program_course.catego...
CREATE TABLE university ( School_ID int, School text, Location text, Founded real, Affiliation text, Enrollment real, Nickname text, Primary_conference text ) CREATE TABLE basketball_match ( Team_ID int, School_ID int, Team_Name text, ACC_Regular_Season text, ACC_Per...
Return a bar chart about the distribution of All_Road and ACC_Percent , and rank in asc by the x axis.
SELECT All_Road, ACC_Percent FROM basketball_match ORDER BY All_Road
CREATE TABLE table_935 ( "Number" real, "Astronaut" text, "Agency" text, "Total EVAs" real, "Total Time Hours:Minutes" text )
How long was the walk numbered at 17?
SELECT "Total Time Hours:Minutes" FROM table_935 WHERE "Number" = '17'
CREATE TABLE table_name_42 ( pim VARCHAR, gf VARCHAR )
What's the P.I.M. for the G.F. of 55?
SELECT pim FROM table_name_42 WHERE gf = "55"
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, ...
out of total number of patients who had other postoperative infection, calculate the number of those from jewish belief?
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"
CREATE TABLE basketball_match ( Team_ID int, School_ID int, Team_Name text, ACC_Regular_Season text, ACC_Percent text, ACC_Home text, ACC_Road text, All_Games text, All_Games_Percent int, All_Home text, All_Road text, All_Neutral text ) CREATE TABLE university ( Scho...
Draw a bar chart about the distribution of ACC_Road and the average of Team_ID , and group by attribute ACC_Road, and I want to sort in desc by the Y-axis.
SELECT ACC_Road, AVG(Team_ID) FROM basketball_match GROUP BY ACC_Road ORDER BY AVG(Team_ID) DESC
CREATE TABLE treatment ( treatmentid number, patientunitstayid number, treatmentname text, treatmenttime time ) CREATE TABLE lab ( labid number, patientunitstayid number, labname text, labresult number, labresulttime time ) CREATE TABLE medication ( medicationid number, pat...
how many hours have passed since the last time patient 006-172277 received a laboratory test of the alt (sgpt) during this hospital visit?
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', lab.labresulttime)) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-172277' AND patient.hos...
CREATE TABLE table_name_36 ( tv_station VARCHAR, average_ratings VARCHAR )
what is the tv station when the average ratings is 19.5%?
SELECT tv_station FROM table_name_36 WHERE average_ratings = "19.5%"
CREATE TABLE table_name_84 ( score_in_final VARCHAR, opponents_in_final VARCHAR )
What was the score when the Shingo Kunieda Satoshi Saida were the opponents?
SELECT score_in_final FROM table_name_84 WHERE opponents_in_final = "shingo kunieda satoshi saida"
CREATE TABLE table_30299 ( "No. in series" real, "No. in season" real, "Title" text, "Directed by" text, "Written by" text, "Original air date" text, "Production code" text, "U.S. viewers (million)" text )
What date did the episode with a production code of 3x6316 originally air?
SELECT "Original air date" FROM table_30299 WHERE "Production code" = '3X6316'
CREATE TABLE table_25429986_1 ( position VARCHAR, number VARCHAR )
what position is number 22?
SELECT position FROM table_25429986_1 WHERE number = 22
CREATE TABLE table_41204 ( "Rank" text, "Nation" text, "Gold" real, "Silver" real, "Bronze" real, "Total" real )
What is the lowest total when the nation is Sweden?
SELECT MIN("Total") FROM table_41204 WHERE "Nation" = 'sweden'
CREATE TABLE table_48662 ( "Province" text, "Region" text, "Capital" text, "Districts" real, "UBIGEO" real )
What is Chep n's average UBIGEO?
SELECT AVG("UBIGEO") FROM table_48662 WHERE "Province" = 'chepén'
CREATE TABLE table_80298 ( "Year" text, "Start" text, "Qual" text, "Rank" text, "Finish" text, "Laps" real )
What year did he start at 13?
SELECT "Year" FROM table_80298 WHERE "Start" = '13'
CREATE TABLE table_5813 ( "Game" real, "Date" text, "Team" text, "Score" text, "High points" text, "High rebounds" text, "Location Attendance" text, "Record" text )
Where is the location of attendance for the Date of december 14?
SELECT "Location Attendance" FROM table_5813 WHERE "Date" = 'december 14'
CREATE TABLE table_67149 ( "Ship" text, "Site" text, "Guns" real, "Naval constructor" text, "Superintendent" text )
What is the site when the superintendent was James Sever?
SELECT "Site" FROM table_67149 WHERE "Superintendent" = 'james sever'
CREATE TABLE table_73034 ( "Township" text, "County" text, "Pop. (2010)" real, "Land ( sqmi )" text, "Water (sqmi)" text, "Latitude" text, "Longitude" text, "GEO ID" real, "ANSI code" real )
What was the land area in sqmi that has a latitude of 48.763937?
SELECT "Land ( sqmi )" FROM table_73034 WHERE "Latitude" = '48.763937'
CREATE TABLE microlab ( microlabid number, patientunitstayid number, culturesite text, organism text, culturetakentime time ) CREATE TABLE patient ( uniquepid text, patienthealthsystemstayid number, patientunitstayid number, gender text, age text, ethnicity text, hospita...
indicate the daily maximum amount of systemicsystolic for patient 035-24054 on their current hospital encounter.
SELECT MAX(vitalperiodic.systemicsystolic) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '035-24054' AND patient.hospitaldischargetime ...
CREATE TABLE CloseReasonTypes ( Id number, Name text, Description text ) CREATE TABLE ReviewTaskResults ( Id number, ReviewTaskId number, ReviewTaskResultTypeId number, CreationDate time, RejectionReasonId number, Comment text ) CREATE TABLE VoteTypes ( Id number, Name text...
Total answers with negative score.
SELECT COUNT(DISTINCT (p.Id)) FROM Posts AS p WHERE p.PostTypeId = 2 AND P.Score < 0
CREATE TABLE table_16439764_1 ( m_v_ft_s INTEGER, time_to_ft__m__at_55°__seconds_ VARCHAR )
What is the maximum foot per second speed where time to feet ratio is 22.1 at 55 degrees?
SELECT MAX(m_v_ft_s) FROM table_16439764_1 WHERE time_to_ft__m__at_55°__seconds_ = "22.1"
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id...
provide the number of patients whose age is less than 50 and diagnoses icd9 code is 5849?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.age < "50" AND diagnoses.icd9_code = "5849"
CREATE TABLE table_9578 ( "Name" text, "Rank" text, "Tenure" text, "Date of death" text, "Cause of death" text )
What is Detective Donald William Schneider's Cause of death?
SELECT "Cause of death" FROM table_9578 WHERE "Rank" = 'detective' AND "Name" = 'donald william schneider'
CREATE TABLE table_name_65 ( gold INTEGER, nation VARCHAR, total VARCHAR )
What is the average gold medals Uzbekistan, which has less than 24 total medals, has?
SELECT AVG(gold) FROM table_name_65 WHERE nation = "uzbekistan" AND total < 24
CREATE TABLE table_15555661_2 ( percentage_of_total_area VARCHAR, area__km²_ VARCHAR )
What is the percentage of total area in the ecozone that the area is 1782252 km2?
SELECT percentage_of_total_area FROM table_15555661_2 WHERE area__km²_ = 1782252
CREATE TABLE table_72276 ( "Name" text, "Location" text, "Light vehicle" text, "Heavy vehicle (2 axles)" text, "Heavy vehicle (3/4 axles)" text, "Heavy vehicle (5+ axles)" text )
What is the toll for light vehicles at the plaza where the toll for heavy vehicles with 2 axles is r87.00?
SELECT "Light vehicle" FROM table_72276 WHERE "Heavy vehicle (2 axles)" = 'R87.00'
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions...
which medication is prescribed to patient with patient id 74345?
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.subject_id = "74345"
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) ...
show me the number of patients who have diagnoses icd9 code 28860 along with additive type drug prescription.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.icd9_code = "28860" AND prescriptions.drug_type = "ADDITIVE"
CREATE TABLE table_60795 ( "Battle" text, "Date" text, "Bulgarian Commander" text, "Byzantine Commander" text, "Result" text )
What is the Date of the Bulgarian Victory at the Battle of Arcadiopolis?
SELECT "Date" FROM table_60795 WHERE "Result" = 'bulgarian victory' AND "Battle" = 'battle of arcadiopolis'
CREATE TABLE table_44723 ( "Date" text, "Time" text, "Score" text, "Set 1" text, "Set 2" text, "Set 3" text, "Total" text )
What is the time when the set 3 score is 31 29?
SELECT "Time" FROM table_44723 WHERE "Set 3" = '31–29'
CREATE TABLE lab ( labid number, patientunitstayid number, labname text, labresult number, labresulttime time ) CREATE TABLE allergy ( allergyid number, patientunitstayid number, drugname text, allergyname text, allergytime time ) CREATE TABLE diagnosis ( diagnosisid number...
when was patient 016-25367 for the last time leaving the hospital during this year?
SELECT patient.hospitaldischargetime FROM patient WHERE patient.uniquepid = '016-25367' AND DATETIME(patient.hospitaldischargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY patient.hospitaldischargetime DESC LIMIT 1
CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), ...
For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about the sum of manager_id over the hire_date bin hire_date by weekday, could you sort Y from high to low order?
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SUM(MANAGER_ID) DESC
CREATE TABLE table_204_200 ( id number, "iso/iec standard" text, "title" text, "status" text, "description" text, "wg" number )
which has the same wg as systems and software engineering - system life cycle processes ?
SELECT "title" FROM table_204_200 WHERE "title" <> 'systems and software engineering - system life cycle processes' AND "wg" = (SELECT "wg" FROM table_204_200 WHERE "title" = 'systems and software engineering - system life cycle processes')
CREATE TABLE table_4662 ( "Home team" text, "Home team score" text, "Away team" text, "Away team score" text, "Venue" text, "Crowd" real, "Date" text )
What is the home team score when st kilda is the away team?
SELECT "Home team score" FROM table_4662 WHERE "Away team" = 'st kilda'
CREATE TABLE table_54813 ( "Driver" text, "Constructor" text, "Laps" real, "Time/Retired" text, "Grid" real )
What is the sum grid number when the driver was Luciano Burti?
SELECT COUNT("Grid") FROM table_54813 WHERE "Driver" = 'luciano burti'
CREATE TABLE VoteTypes ( Id number, Name text ) CREATE TABLE SuggestedEditVotes ( Id number, SuggestedEditId number, UserId number, VoteTypeId number, CreationDate time, TargetUserId number, TargetRepChange number ) CREATE TABLE Badges ( Id number, UserId number, Name t...
PPCG: Many more Q's than A's.
SELECT U.Id, U.DisplayName, Q.Questions, A.Answers FROM Users AS U INNER JOIN (SELECT OwnerUserId, COUNT(*) AS Questions FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId) AS Q ON U.Id = Q.OwnerUserId INNER JOIN (SELECT OwnerUserId, COUNT(*) AS Answers FROM Posts WHERE PostTypeId = 2 GROUP BY OwnerUserId) AS A ON Q....
CREATE TABLE table_16725 ( "Rnd" real, "Race" text, "Date" text, "Location" text, "Pole Position" text, "Fastest Lap" text, "Race Winner" text, "Constructor" text, "Report" text )
Who did the fastest lap with the race winner john watson?
SELECT "Fastest Lap" FROM table_16725 WHERE "Race Winner" = 'John Watson'
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob te...
specify the drug name patient id 6983 is treated with?
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.subject_id = "6983"
CREATE TABLE table_9956 ( "Place" text, "Player" text, "Country" text, "Score" text, "To par" text, "Money ($)" text )
What is T3 Place Player Bobby Locke's Score?
SELECT "Score" FROM table_9956 WHERE "Place" = 't3' AND "Player" = 'bobby locke'
CREATE TABLE table_73601 ( "Name" text, "Location" text, "Act. Units" real, "Stacks" text, "In Service Dates" text, "Unit Capacity (2009)" text, "Nameplate Capacity (2009 MW )" text, "Owner Type" text, "Owner(s) (2009)" text )
Name the number for service dates for hoosier energy for petersburg
SELECT COUNT("In Service Dates") FROM table_73601 WHERE "Owner(s) (2009)" = 'Hoosier Energy' AND "Location" = 'Petersburg'
CREATE TABLE table_43060 ( "Date" text, "Cover model" text, "Centerfold model" text, "Interview subject" text, "20 Questions" text )
Who was the Cover model when the Centerfold Model was Marketa Janska?
SELECT "Cover model" FROM table_43060 WHERE "Centerfold model" = 'marketa janska'
CREATE TABLE Votes ( Id number, PostId number, VoteTypeId number, UserId number, CreationDate time, BountyAmount number ) CREATE TABLE PostNoticeTypes ( Id number, ClassId number, Name text, Body text, IsHidden boolean, Predefined boolean, PostNoticeDurationId number...
LIST ALL T-SQL DATETIME FORMATS (plus example of TRY..CATCH).
SELECT CAST(TIME_TO_STR(CURRENT_TIMESTAMP(), '%d %b %Y %H:%M:%S:%f') AS TEXT(30))
CREATE TABLE table_name_4 ( date VARCHAR, score VARCHAR, opponent VARCHAR )
What date was the match against leonardo tavares with a score of 6 4, 6 4?
SELECT date FROM table_name_4 WHERE score = "6–4, 6–4" AND opponent = "leonardo tavares"
CREATE TABLE intakeoutput ( intakeoutputid number, patientunitstayid number, cellpath text, celllabel text, cellvaluenumeric number, intakeoutputtime time ) CREATE TABLE cost ( costid number, uniquepid text, patienthealthsystemstayid number, eventtype text, eventid number, ...
today the respiration of patient 003-10080 was ever less than 15.0?
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-10080')) AND vitalperiodic.respiration < 15.0 AND NOT vitalperio...
CREATE TABLE table_19359427_6 ( date_of_vacancy VARCHAR, team VARCHAR )
When did the old manager vacate his position in Plymouth Argyle?
SELECT date_of_vacancy FROM table_19359427_6 WHERE team = "Plymouth Argyle"
CREATE TABLE table_name_64 ( partner VARCHAR, score VARCHAR )
Who was Silva's Partner in the match with a Score of 6 3, 7 6 (7 3)?
SELECT partner FROM table_name_64 WHERE score = "6–3, 7–6 (7–3)"
CREATE TABLE table_73063 ( "Parliament" text, "Name" text, "Period in office" text, "Birth and death years" text, "General election contested" real, "Constituency contested" text, "Political party" text )
what parliament's name is lina loh woon lee?
SELECT "Parliament" FROM table_73063 WHERE "Name" = 'Lina Loh Woon Lee'
CREATE TABLE table_name_20 ( venue VARCHAR, result VARCHAR )
In what venue was the result a draw?
SELECT venue FROM table_name_20 WHERE result = "draw"
CREATE TABLE route ( train_id int, station_id int ) CREATE TABLE weekly_weather ( station_id int, day_of_week text, high_temperature int, low_temperature int, precipitation real, wind_speed_mph int ) CREATE TABLE train ( id int, train_number int, name text, origin text,...
Show me the proportion of times and numbers of all trains that go to Chennai with a pie chart.
SELECT time, train_number FROM train WHERE destination = 'Chennai'
CREATE TABLE table_name_85 ( score VARCHAR, date VARCHAR )
What is Score, when Date is February 5?
SELECT score FROM table_name_85 WHERE date = "february 5"
CREATE TABLE vitalperiodic ( vitalperiodicid number, patientunitstayid number, temperature number, sao2 number, heartrate number, respiration number, systemicsystolic number, systemicdiastolic number, systemicmean number, observationtime time ) CREATE TABLE allergy ( allergy...
what are the four most frequent drugs prescribed to the patients of 60 or above after being diagnosed with hypophosphatemia during the same month?
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hypophosphatemia') AS t1 JOIN (SELECT patient.uniq...
CREATE TABLE table_67914 ( "Exam" text, "2006 First Time" text, "2006 All" text, "2007 First Time" text, "2007 All" text, "2008 First Time" text, "2008 All" text, "2009 First Time" text, "2009 All" text, "2010 First Time" text, "2011 First Time" text, "2012 First Time" te...
What is the 2009 all percentage of the exam with a 2007 first time percentage of 49%?
SELECT "2009 All" FROM table_67914 WHERE "2007 First Time" = '49%'
CREATE TABLE table_name_88 ( competition VARCHAR, score VARCHAR )
Which competition has 4-0 as the score?
SELECT competition FROM table_name_88 WHERE score = "4-0"
CREATE TABLE table_name_98 ( year INTEGER, drivers VARCHAR, poles VARCHAR, fast_laps VARCHAR )
What is the average Year during which the Driver Adrian Quaife-Hobbs has fewer than 2 Poles, and 0 Fast laps?
SELECT AVG(year) FROM table_name_98 WHERE poles < 2 AND fast_laps = 0 AND drivers = "adrian quaife-hobbs"
CREATE TABLE table_23659 ( "Season" real, "Division" text, "Coach" text, "Overall Record" text, "Conference Record" text, "Result" text, "Attendance" real )
In what season was the conference record 4-3?
SELECT MIN("Season") FROM table_23659 WHERE "Conference Record" = '4-3'
CREATE TABLE table_27756164_2 ( score VARCHAR, high_points VARCHAR )
What was the score of the game in which Danny Granger (30) did the high points?
SELECT score FROM table_27756164_2 WHERE high_points = "Danny Granger (30)"
CREATE TABLE class_of_service ( booking_class varchar, rank int, class_description text ) CREATE TABLE time_interval ( period text, begin_time int, end_time int ) CREATE TABLE city ( city_code varchar, city_name varchar, state_code varchar, country_name varchar, time_zone_c...
show last flight from PHILADELPHIA to BOSTON
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = '...
CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), CO...
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, show me about the change of department_id over hire_date in a line chart, rank by the HIRE_DATE in asc.
SELECT HIRE_DATE, DEPARTMENT_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY HIRE_DATE
CREATE TABLE table_35842 ( "Name" text, "Date" text, "Goals" real, "Assists" real, "Team" text, "Venue" text, "Opponent" text, "Competition" text, "Total Goals" real, "Total Assists" real )
Who was the opponent at the competition held at Jeonju?
SELECT "Opponent" FROM table_35842 WHERE "Venue" = 'jeonju'
CREATE TABLE table_13050003_2 ( year INTEGER, blocks VARCHAR )
What year has Nerlens Noel (4) as blocker?
SELECT MIN(year) FROM table_13050003_2 WHERE blocks = "Nerlens Noel (4)"
CREATE TABLE table_name_30 ( score VARCHAR, player VARCHAR )
What is the score of player bill rogers?
SELECT score FROM table_name_30 WHERE player = "bill rogers"
CREATE TABLE track ( Track_ID int, Name text, Location text, Seating real, Year_Opened real ) CREATE TABLE race ( Race_ID int, Name text, Class text, Date text, Track_ID text )
Show the name of track and the number of races in each track Visualize by bar chart, order in desc by the Name.
SELECT T2.Name, COUNT(*) FROM race AS T1 JOIN track AS T2 ON T1.Track_ID = T2.Track_ID GROUP BY T1.Track_ID ORDER BY T2.Name DESC
CREATE TABLE table_5756 ( "County" text, "Per capita income" text, "Median household income" text, "Median family income" text, "Population" real, "Number of households" real )
How many people have a Median household income of $37,759?
SELECT SUM("Population") FROM table_5756 WHERE "Median household income" = '$37,759'
CREATE TABLE table_name_56 ( score VARCHAR, opponent_in_the_final VARCHAR )
What was the score of the game against Divij Sharan?
SELECT score FROM table_name_56 WHERE opponent_in_the_final = "divij sharan"
CREATE TABLE course ( course_id int, name varchar, department varchar, number varchar, credits varchar, advisory_requirement varchar, enforced_requirement varchar, description varchar, num_semesters int, num_enrolled int, has_discussion varchar, has_lab varchar, has_p...
For the Core course , who is the easiest teacher ?
SELECT DISTINCT instructor.name, program_course.workload FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN program_course ON program_course.course_id = cour...
CREATE TABLE program_requirement ( program_id int, category varchar, min_credit int, additional_req varchar ) CREATE TABLE gsi ( course_offering_id int, student_id int ) CREATE TABLE course_tags_count ( course_id int, clear_grading int, pop_quiz int, group_projects int, ins...
Of all the courses I have completed , which was the most difficult ?
SELECT DISTINCT course.department, course.name, course.number, program_course.workload FROM course INNER JOIN student_record ON student_record.course_id = course.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE program_course.workload = (SELECT MAX(PROGRAM_COURSEalias1.workload) ...
CREATE TABLE d_icd_diagnoses ( row_id number, icd9_code text, short_title text, long_title text ) CREATE TABLE d_items ( row_id number, itemid number, label text, linksto text ) CREATE TABLE chartevents ( row_id number, subject_id number, hadm_id number, icustay_id numb...
what are the top three most frequent procedures that patients received during the same hospital visit after they were diagnosed with sec malig neo nerve nec until 2104?
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t3.icd9_code FROM (SELECT t2.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, diagnoses_icd.charttime, admissions.hadm_id FROM diagnoses_icd JOIN admissions ON diagnoses_i...
CREATE TABLE table_name_61 ( region VARCHAR, date VARCHAR )
What is Region, when Date is 2004?
SELECT region FROM table_name_61 WHERE date = 2004
CREATE TABLE offering_instructor ( offering_instructor_id int, offering_id int, instructor_id int ) CREATE TABLE requirement ( requirement_id int, requirement varchar, college varchar ) CREATE TABLE course_offering ( offering_id int, course_id int, semester int, section_number ...
Which classes are allowed for PreMajor this coming semester ?
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program, program_course, semester WHERE course.course_id = course_offering.course_id AND program_course.category LIKE '%PreMajor%' AND program_course.course_id = course.course_id AND program.name LIKE '%CS-LSA%' AND program.prog...
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, ...
what is the drug type of subject id 76446?
SELECT prescriptions.drug_type FROM prescriptions WHERE prescriptions.subject_id = "76446"
CREATE TABLE table_3411 ( "No." real, "#" real, "Episode" text, "Writer" text, "Director" text, "Original air date" text, "Viewing figure" real )
How many items are listed under the column 'viewing figure' for 'the looking glass'?
SELECT COUNT("Viewing figure") FROM table_3411 WHERE "Episode" = 'The Looking Glass'
CREATE TABLE table_63235 ( "Engine" text, "Production" text, "Transmission" text, "Power" text, "Torque" text, "Acceleration 0\u2013100km/h (0\u201362mph)" text, "Top Speed" text )
What is the transmission when the engine is 2.0l, and acceleration 0 100km/h (0 62mph) is 10.5 s?
SELECT "Transmission" FROM table_63235 WHERE "Engine" = '2.0l' AND "Acceleration 0\u2013100km/h (0\u201362mph)" = '10.5 s'
CREATE TABLE table_204_636 ( id number, "season" text, "tier" number, "division" text, "pos." text, "notes" text )
what was the least successful season ?
SELECT "season" FROM table_204_636 ORDER BY "pos." DESC LIMIT 1
CREATE TABLE table_19564 ( "Rank" real, "Country" text, "International tourist arrivals (2011)" text, "International tourist arrivals (2010)" text, "Change (2010 to 2011)" text, "Change (2009 to 2010)" text )
What are the changes from 2009 to 2010 in Tunisia?
SELECT "Change (2009 to 2010)" FROM table_19564 WHERE "Country" = 'Tunisia'
CREATE TABLE table_73192 ( "Season" text, "RL S\u00fcd (1st)" text, "RL S\u00fcd (2nd)" text, "RL S\u00fcdwest (1st)" text, "RL S\u00fcdwest (2nd)" text )
What season was Freiburger FC the RL S d (2nd) team?
SELECT "Season" FROM table_73192 WHERE "RL S\u00fcd (2nd)" = 'Freiburger FC'
CREATE TABLE table_79606 ( "Tie no" text, "Home team" text, "Score" text, "Away team" text, "Attendance" text )
What was the score when there were 7 ties?
SELECT "Score" FROM table_79606 WHERE "Tie no" = '7'