VishalCh/book-train huggingface dataset:
Schema:
CREATE TABLE phone_market (
    Market_ID int,
    Phone_ID text,
    Num_of_stock int
)

CREATE TABLE market (
    Market_ID int,
    District text,
    Num_of_employees int,
    Num_of_shops real,
    Ranking int
)

CREATE TABLE phone (
    Name text,
    Phone_ID int,
    Memory_in_G int,
    Carrier text,
    Price real
)

Question: What are the memories and carriers of phones Show bar chart, and show by the mean memory in g in descending.

SQL:
SELECT Carrier, AVG(Memory_in_G) FROM phone GROUP BY Carrier ORDER BY AVG(Memory_in_G) DESC
Schema:
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 text,
    discharge_location text,
    diagnosis text,
    dod text,
    dob_year text,
    dod_year text,
    admittime text,
    dischtime text,
    admityear text
)

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 lab (
    subject_id text,
    hadm_id text,
    itemid text,
    charttime text,
    flag text,
    value_unit text,
    label text,
    fluid 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
)

Question: what is the number of patients whose death status is 1 and diagnoses icd9 code is 261?

SQL:
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.icd9_code = "261"
Schema:
CREATE TABLE table_51383 (
    "Rank" real,
    "Nation" text,
    "Gold" real,
    "Silver" real,
    "Bronze" real,
    "Total" real
)

Question: When the Total is less than 1, and Bronze is 0, how many Gold medals are there?

SQL:
SELECT SUM("Gold") FROM table_51383 WHERE "Bronze" = '0' AND "Total" < '1'
Schema:
CREATE TABLE table_name_40 (
    game INTEGER,
    march VARCHAR
)

Question: March of 29 involves what highest scoring game?

SQL:
SELECT MAX(game) FROM table_name_40 WHERE march = 29
Schema:
CREATE TABLE table_72086 (
    "No. in set" real,
    "No. in series" real,
    "Title" text,
    "Directed by" text,
    "Written by" text,
    "Original air date" text,
    "Production code" text
)

Question: The episode with production code 9abx02 was originally aired on what date?

SQL:
SELECT "Original air date" FROM table_72086 WHERE "Production code" = '9ABX02'
Schema:
CREATE TABLE table_19423 (
    "State/UT Code" real,
    "India/State/UT" text,
    "Literate Persons (%)" text,
    "Males (%)" text,
    "Females (%)" text
)

Question: What is the percentage of females where in India and are maharashtra?

SQL:
SELECT "Females (%)" FROM table_19423 WHERE "India/State/UT" = 'Maharashtra'
Schema:
CREATE TABLE county_public_safety (
    county_id number,
    name text,
    population number,
    police_officers number,
    residents_per_officer number,
    case_burden number,
    crime_rate number,
    police_force text,
    location text
)

CREATE TABLE city (
    city_id number,
    county_id number,
    name text,
    white number,
    black number,
    amerindian number,
    asian number,
    multiracial number,
    hispanic number
)

Question: Show the name of cities in the county that has the largest number of police officers.

SQL:
SELECT name FROM city WHERE county_id = (SELECT county_id FROM county_public_safety ORDER BY police_officers DESC LIMIT 1)
Schema:
CREATE TABLE table_50536 (
    "Season" text,
    "Skip" text,
    "Third" text,
    "Second" text,
    "Lead" text
)

Question: What is the skip that has a third of Anna Sloan in season 2012-13?

SQL:
SELECT "Skip" FROM table_50536 WHERE "Third" = 'anna sloan' AND "Season" = '2012-13'
Schema:
CREATE TABLE table_name_12 (
    time_retired VARCHAR,
    grid VARCHAR
)

Question: I want the time/retired for grid of 24

SQL:
SELECT time_retired FROM table_name_12 WHERE grid = 24
Schema:
CREATE TABLE table_38310 (
    "Start month" text,
    "End month" text,
    "Cover" text,
    "Spine" text,
    "Indicia" text,
    "Masthead" text,
    "Number of issues" real
)

Question: Which spine has 12 issues?

SQL:
SELECT "Spine" FROM table_38310 WHERE "Number of issues" = '12'
Schema:
CREATE TABLE table_32109 (
    "Year" real,
    "Play" text,
    "Role" text,
    "Theatre" text,
    "Location" text
)

Question: Tell me the lowest year for shubert theatre

SQL:
SELECT MIN("Year") FROM table_32109 WHERE "Theatre" = 'shubert theatre'
Schema:
CREATE TABLE table_11250_4 (
    top_division_titles INTEGER
)

Question: What is the least top division titles?

SQL:
SELECT MIN(top_division_titles) FROM table_11250_4
Schema:
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,
    hospitaladmitsource text,
    unitadmittime time,
    unitdischargetime time,
    hospitaldischargetime time,
    hospitaldischargestatus text
)

CREATE TABLE allergy (
    allergyid number,
    patientunitstayid number,
    drugname text,
    allergyname text,
    allergytime time
)

CREATE TABLE intakeoutput (
    intakeoutputid number,
    patientunitstayid number,
    cellpath text,
    celllabel text,
    cellvaluenumeric number,
    intakeoutputtime time
)

CREATE TABLE lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime time
)

CREATE TABLE medication (
    medicationid number,
    patientunitstayid number,
    drugname text,
    dosage text,
    routeadmin text,
    drugstarttime time,
    drugstoptime time
)

CREATE TABLE treatment (
    treatmentid number,
    patientunitstayid number,
    treatmentname text,
    treatmenttime time
)

CREATE TABLE microlab (
    microlabid number,
    patientunitstayid number,
    culturesite text,
    organism text,
    culturetakentime time
)

CREATE TABLE cost (
    costid number,
    uniquepid text,
    patienthealthsystemstayid number,
    eventtype text,
    eventid number,
    chargetime time,
    cost number
)

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 diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

Question: calculate the duration of hospital stay of patient 010-20205's last hospital stay.

SQL:
SELECT STRFTIME('%j', patient.hospitaldischargetime) - STRFTIME('%j', patient.hospitaladmittime) FROM patient WHERE patient.uniquepid = '010-20205' AND NOT patient.hospitaladmittime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1
Schema:
CREATE TABLE table_43511 (
    "Season" text,
    "Competition" text,
    "Round" text,
    "Opponent" text,
    "Home" text,
    "Away" text
)

Question: Which round has an opponent of Freiburg?

SQL:
SELECT "Round" FROM table_43511 WHERE "Opponent" = 'freiburg'
Schema:
CREATE TABLE table_11104 (
    "Suburb" text,
    "Population (in 2008)" real,
    "Median age (in 2006)" text,
    "Mean household size (in 2006)" text,
    "Area (km\u00b2)" real,
    "Density (/km\u00b2)" real,
    "Date first settled as a suburb" real,
    "Gazetted as a Division Name" text
)

Question: What's the Area with a Density of 263?

SQL:
SELECT AVG("Area (km\u00b2)") FROM table_11104 WHERE "Density (/km\u00b2)" = '263'
Schema:
CREATE TABLE table_name_4 (
    position VARCHAR,
    years_for_rockets VARCHAR
)

Question: For the years 1992-93, what position did he play for the Houston Rockets?

SQL:
SELECT position FROM table_name_4 WHERE years_for_rockets = "1992-93"
Schema:
CREATE TABLE table_23308178_8 (
    points INTEGER
)

Question: What is the largest number of points they had?

SQL:
SELECT MAX(points) FROM table_23308178_8
Schema:
CREATE TABLE table_10315 (
    "Sport" text,
    "Gold" real,
    "Silver" real,
    "Bronze" real,
    "Total" real
)

Question: Tell me the total number of Bronze for futsal

SQL:
SELECT COUNT("Bronze") FROM table_10315 WHERE "Sport" = 'futsal'
Schema:
CREATE TABLE table_18373863_2 (
    year_drafted INTEGER,
    years_played VARCHAR
)

Question: When 2005 is the year played what is the lowest year drafted?

SQL:
SELECT MIN(year_drafted) FROM table_18373863_2 WHERE years_played = "2005"
Schema:
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_Percent text,
    ACC_Home text,
    ACC_Road text,
    All_Games text,
    All_Games_Percent int,
    All_Home text,
    All_Road text,
    All_Neutral text
)

Question: Show me about the distribution of All_Road and All_Games_Percent in a bar chart, and I want to show by the names in desc please.

SQL:
SELECT All_Road, All_Games_Percent FROM basketball_match ORDER BY All_Road DESC

Question: Find the total number of students enrolled in the colleges that were founded after the year of 1850 for each affiliation type Show bar chart, I want to sort X-axis from low to high order please.

SQL:
SELECT Affiliation, SUM(Enrollment) FROM university WHERE Founded > 1850 GROUP BY Affiliation ORDER BY Affiliation

Question: Give me the comparison about School_ID over the ACC_Road , and group by attribute ACC_Home by a bar chart, and order by the bars in desc.

SQL:
SELECT ACC_Road, School_ID FROM basketball_match GROUP BY ACC_Home, ACC_Road ORDER BY ACC_Road DESC
Schema:
CREATE TABLE table_59025 (
    "Stage" text,
    "Winner" text,
    "General Classification" text,
    "Mountains Classification" text,
    "Points Classification" text,
    "Sprints classification" text,
    "Team Classification" text
)

Question: What's the general classification of stage 3 with David Loosli as the mountains classification?

SQL:
SELECT "General Classification" FROM table_59025 WHERE "Mountains Classification" = 'david loosli' AND "Stage" = '3'
Schema:
CREATE TABLE table_19156 (
    "High School" text,
    "Type" text,
    "Established" real,
    "Enrollment" real,
    "Mascot" text,
    "WIAA Classification" text,
    "Notes" text
)

Question: When was Mount Tahoma established?

SQL:
SELECT MAX("Established") FROM table_19156 WHERE "High School" = 'Mount Tahoma'
Schema:
CREATE TABLE table_2221484_2 (
    directed_by VARCHAR,
    series__number VARCHAR
)

Question: Who directed episode 266 in the series?

SQL:
SELECT directed_by FROM table_2221484_2 WHERE series__number = 266
Schema:
CREATE TABLE table_name_10 (
    date VARCHAR,
    tournament VARCHAR
)

Question: When did the Tournament of the Tour Championship take place?

SQL:
SELECT date FROM table_name_10 WHERE tournament = "the tour championship"
Schema:
CREATE TABLE table_48114 (
    "Province" text,
    "Largest city" text,
    "2nd Largest" text,
    "3rd Largest" text,
    "4th largest" text
)

Question: What province has the largest city of Birjand?

SQL:
SELECT "Province" FROM table_48114 WHERE "Largest city" = 'birjand'
Schema:
CREATE TABLE Events (
    Event_ID INTEGER,
    Service_ID INTEGER,
    Event_Details VARCHAR(255)
)

CREATE TABLE Participants_in_Events (
    Event_ID INTEGER,
    Participant_ID INTEGER
)

CREATE TABLE Participants (
    Participant_ID INTEGER,
    Participant_Type_Code CHAR(15),
    Participant_Details VARCHAR(255)
)

CREATE TABLE Services (
    Service_ID INTEGER,
    Service_Type_Code CHAR(15)
)

Question: Group and count details for the events using a pie chart.

SQL:
SELECT Event_Details, COUNT(Event_Details) FROM Events GROUP BY Event_Details
Schema:
CREATE TABLE table_name_60 (
    area__km_2__ VARCHAR,
    common_of VARCHAR,
    population VARCHAR
)

Question: How much Area (km 2) has a Common of collegno, and a Population smaller than 50137?

SQL:
SELECT COUNT(area__km_2__) FROM table_name_60 WHERE common_of = "collegno" AND population < 50137
Schema:
CREATE TABLE table_67978 (
    "7:00" text,
    "7:30" text,
    "8:00" text,
    "8:30" text,
    "9:00" text,
    "9:30" text,
    "10:00" text,
    "10:30" text
)

Question: What 7:00 has a 10:00 of dirty sexy money?

SQL:
SELECT "7:00" FROM table_67978 WHERE "10:00" = 'dirty sexy money'
Schema:
CREATE TABLE table_21872 (
    "Fin. Pos" real,
    "Car No." real,
    "Driver" text,
    "Team" text,
    "Laps" real,
    "Time/Retired" text,
    "Grid" real,
    "Laps Led" real,
    "Points" text
)

Question: If the driver is Milka Duno, what is the name of the team?

SQL:
SELECT "Team" FROM table_21872 WHERE "Driver" = 'Milka Duno'
Schema:
CREATE TABLE table_8817 (
    "Place" text,
    "Player" text,
    "Country" text,
    "Score" text,
    "To par" text
)

Question: In what place did Dave Barr score?

SQL:
SELECT "Place" FROM table_8817 WHERE "Player" = 'dave barr'
Schema:
CREATE TABLE table_name_87 (
    laps INTEGER,
    constructor VARCHAR,
    grid VARCHAR,
    time_retired VARCHAR
)

Question: What is the average laps for a grid larger than 2, for a ferrari that got in an accident?

SQL:
SELECT AVG(laps) FROM table_name_87 WHERE grid > 2 AND time_retired = "accident" AND constructor = "ferrari"
Schema:
CREATE TABLE table_40678 (
    "Television service" text,
    "Country" text,
    "Language" text,
    "Content" text,
    "HDTV" text,
    "Package/Option" text
)

Question: What Country's Content is TV Locale?

SQL:
SELECT "Country" FROM table_40678 WHERE "Content" = 'tv locale'
Schema:
CREATE TABLE table_29843 (
    "Game" real,
    "Date" text,
    "Team" text,
    "Score" text,
    "High points" text,
    "High rebounds" text,
    "High assists" text,
    "Location Attendance" text,
    "Record" text
)

Question: Who had the high rebounds when the record was 14 7?

SQL:
SELECT "High rebounds" FROM table_29843 WHERE "Record" = '14–7'
Schema:
CREATE TABLE table_68355 (
    "Place" text,
    "Player" text,
    "Country" text,
    "Score" text,
    "To par" text,
    "Money ( \u00a3 )" text
)

Question: Name the money for p draig harrington

SQL:
SELECT "Money ( \u00a3 )" FROM table_68355 WHERE "Player" = 'pádraig harrington'
Schema:
CREATE TABLE table_64405 (
    "Date" text,
    "Opponent" text,
    "Score" text,
    "Loss" text,
    "Attendance" real,
    "Record" text,
    "Arena" text,
    "Points" real
)

Question: Which Date has a Record of 19 16 8?

SQL:
SELECT "Date" FROM table_64405 WHERE "Record" = '19–16–8'
Schema:
CREATE TABLE table_66876 (
    "Sunday Sunna/S\u00f3l" text,
    "Monday Mona/ M\u00e1ni" text,
    "Tuesday Tiw/ Tyr" text,
    "Wednesday Woden / Odin" text,
    "Thursday Thunor / Thor" text,
    "Friday Frige or Freya" text,
    "Saturday Saturn" text
)

Question: Which Monday Mona/Mani also had a Thursday Thunor/Thor of Tongersdei?

SQL:
SELECT "Monday Mona/ M\u00e1ni" FROM table_66876 WHERE "Thursday Thunor / Thor" = 'tongersdei'
Schema:
CREATE TABLE table_79725 (
    "Date" text,
    "Opponent" text,
    "Score" text,
    "Loss" text,
    "Record" text
)

Question: What's the loss for September 16?

SQL:
SELECT "Loss" FROM table_79725 WHERE "Date" = 'september 16'
Schema:
CREATE TABLE table_14940519_1 (
    week VARCHAR,
    game_site VARCHAR,
    opponent VARCHAR
)

Question: Name the number of week for game site being memorial stadium for buffalo bills

SQL:
SELECT COUNT(week) FROM table_14940519_1 WHERE game_site = "Memorial Stadium" AND opponent = "Buffalo Bills"
Schema:
CREATE TABLE table_51904 (
    "Club" text,
    "Head Coach" text,
    "City" text,
    "Stadium" text,
    "2006-2007 season" text
)

Question: Where did the Vit ria de Set bal club place in the 2006-2007 season?

SQL:
SELECT "2006-2007 season" FROM table_51904 WHERE "Club" = 'vitória de setúbal'
Schema:
CREATE TABLE Student (
    StuID INTEGER,
    LName VARCHAR(12),
    Fname VARCHAR(12),
    Age INTEGER,
    Sex VARCHAR(1),
    Major INTEGER,
    Advisor INTEGER,
    city_code VARCHAR(3)
)

CREATE TABLE Has_Allergy (
    StuID INTEGER,
    Allergy VARCHAR(20)
)

CREATE TABLE Allergy_Type (
    Allergy VARCHAR(20),
    AllergyType VARCHAR(20)
)

Question: How many students does each advisor have. Show scatter chart.

SQL:
SELECT Advisor, COUNT(*) FROM Student GROUP BY Advisor
Schema:
CREATE TABLE table_68311 (
    "Name" text,
    "Birth" text,
    "Marriage" text,
    "Became Consort" text,
    "Ceased to be Consort" text,
    "Spouse" text
)

Question: Name the birth of the person married 24 may 1935

SQL:
SELECT "Birth" FROM table_68311 WHERE "Marriage" = '24 may 1935'
Schema:
CREATE TABLE table_name_52 (
    attendance INTEGER,
    score VARCHAR
)

Question: How many attended during the game with a score of 80-94?

SQL:
SELECT SUM(attendance) FROM table_name_52 WHERE score = "80-94"
Schema:
CREATE TABLE Asset_Parts (
    asset_id INTEGER,
    part_id INTEGER
)

CREATE TABLE Skills (
    skill_id INTEGER,
    skill_code VARCHAR(20),
    skill_description VARCHAR(255)
)

CREATE TABLE Fault_Log_Parts (
    fault_log_entry_id INTEGER,
    part_fault_id INTEGER,
    fault_status VARCHAR(10)
)

CREATE TABLE Staff (
    staff_id INTEGER,
    staff_name VARCHAR(255),
    gender VARCHAR(1),
    other_staff_details VARCHAR(255)
)

CREATE TABLE Maintenance_Engineers (
    engineer_id INTEGER,
    company_id INTEGER,
    first_name VARCHAR(50),
    last_name VARCHAR(50),
    other_details VARCHAR(255)
)

CREATE TABLE Third_Party_Companies (
    company_id INTEGER,
    company_type VARCHAR(5),
    company_name VARCHAR(255),
    company_address VARCHAR(255),
    other_company_details VARCHAR(255)
)

CREATE TABLE Fault_Log (
    fault_log_entry_id INTEGER,
    asset_id INTEGER,
    recorded_by_staff_id INTEGER,
    fault_log_entry_datetime DATETIME,
    fault_description VARCHAR(255),
    other_fault_details VARCHAR(255)
)

CREATE TABLE Parts (
    part_id INTEGER,
    part_name VARCHAR(255),
    chargeable_yn VARCHAR(1),
    chargeable_amount VARCHAR(20),
    other_part_details VARCHAR(255)
)

CREATE TABLE Part_Faults (
    part_fault_id INTEGER,
    part_id INTEGER,
    fault_short_name VARCHAR(20),
    fault_description VARCHAR(255),
    other_fault_details VARCHAR(255)
)

CREATE TABLE Engineer_Visits (
    engineer_visit_id INTEGER,
    contact_staff_id INTEGER,
    engineer_id INTEGER,
    fault_log_entry_id INTEGER,
    fault_status VARCHAR(10),
    visit_start_datetime DATETIME,
    visit_end_datetime DATETIME,
    other_visit_details VARCHAR(255)
)

CREATE TABLE Engineer_Skills (
    engineer_id INTEGER,
    skill_id INTEGER
)

CREATE TABLE Assets (
    asset_id INTEGER,
    maintenance_contract_id INTEGER,
    supplier_company_id INTEGER,
    asset_details VARCHAR(255),
    asset_make VARCHAR(20),
    asset_model VARCHAR(20),
    asset_acquired_date DATETIME,
    asset_disposed_date DATETIME,
    other_asset_details VARCHAR(255)
)

CREATE TABLE Maintenance_Contracts (
    maintenance_contract_id INTEGER,
    maintenance_contract_company_id INTEGER,
    contract_start_date DATETIME,
    contract_end_date DATETIME,
    other_contract_details VARCHAR(255)
)

CREATE TABLE Skills_Required_To_Fix (
    part_fault_id INTEGER,
    skill_id INTEGER
)

Question: Draw a bar chart of asset make versus the number of asset make, and display in asc by the X.

SQL:
SELECT asset_make, COUNT(asset_make) FROM Assets GROUP BY asset_make ORDER BY asset_make
Schema:
CREATE TABLE table_32374 (
    "Season" text,
    "Team" text,
    "League Apps" real,
    "League Goals" real,
    "Cup Apps" real,
    "Cup Goals" real
)

Question: How many cop apps in the season with fewer than 12 league apps?

SQL:
SELECT SUM("Cup Apps") FROM table_32374 WHERE "League Apps" < '12'
Schema:
CREATE TABLE table_name_89 (
    competition VARCHAR,
    club VARCHAR
)

Question: What competition has the club villareal?

SQL:
SELECT competition FROM table_name_89 WHERE club = "villareal"
Schema:
CREATE TABLE table_203_214 (
    id number,
    "member" text,
    "party" text,
    "electorate" text,
    "state" text,
    "first elected" text
)

Question: when was joe clark first elected ?

SQL:
SELECT "first elected" FROM table_203_214 WHERE "member" = 'joe clark'
Schema:
CREATE TABLE mission (
    Mission_ID int,
    Ship_ID int,
    Code text,
    Launched_Year int,
    Location text,
    Speed_knots int,
    Fate text
)

CREATE TABLE ship (
    Ship_ID int,
    Name text,
    Type text,
    Nationality text,
    Tonnage int
)

Question: Bar graph to show how many nationality from different nationality, list in desc by the total number.

SQL:
SELECT Nationality, COUNT(Nationality) FROM ship GROUP BY Nationality ORDER BY COUNT(Nationality) DESC