VishalCh/book-train huggingface dataset:
Schema:
CREATE TABLE table_1160660_1 (
    date_founded VARCHAR,
    acronym VARCHAR
)

Question: What year was USF founded?

SQL:
SELECT date_founded FROM table_1160660_1 WHERE acronym = "USF"
Schema:
CREATE TABLE table_64562 (
    "Team" text,
    "Outgoing manager" text,
    "Manner of departure" text,
    "Date of vacancy" text,
    "Replaced by" text,
    "Date of appointment" text,
    "Position in table" text
)

Question: what is the position in table when the team is hartlepool united?

SQL:
SELECT "Position in table" FROM table_64562 WHERE "Team" = 'hartlepool united'
Schema:
CREATE TABLE table_17065 (
    "Player" text,
    "Position" text,
    "School" text,
    "Hometown" text,
    "College" text
)

Question: What was the position of the player from Butler High School?

SQL:
SELECT "Position" FROM table_17065 WHERE "School" = 'Butler High School'
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 lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime time
)

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

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

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 treatment (
    treatmentid number,
    patientunitstayid number,
    treatmentname text,
    treatmenttime time
)

CREATE TABLE diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

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

CREATE TABLE vitalperiodic (
    vitalperiodicid number,
    patientunitstayid number,
    temperature number,
    sao2 number,
    heartrate number,
    respiration number,
    systemicsystolic number,
    systemicdiastolic number,
    systemicmean number,
    observationtime time
)

Question: how many prescriptions for multivitamins have been ordered?

SQL:
SELECT COUNT(*) FROM medication WHERE medication.drugname = 'multivitamins'
Schema:
CREATE TABLE table_52794 (
    "Analog Channel" text,
    "Digital Channel" text,
    "Call sign" text,
    "Name" text,
    "Network" text
)

Question: Which analog channel is Fox on?

SQL:
SELECT "Analog Channel" FROM table_52794 WHERE "Network" = 'fox'
Schema:
CREATE TABLE table_204_373 (
    id number,
    "wager" text,
    "winner" text,
    "loser" text,
    "location" text,
    "date" text
)

Question: first opponent to defeat mocho cota in mexico city

SQL:
SELECT "winner" FROM table_204_373 WHERE "loser" = 'mocho cota' AND "location" = 'mexico city' ORDER BY "date" LIMIT 1
Schema:
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 diagnoses (
    subject_id text,
    hadm_id text,
    icd9_code text,
    short_title text,
    long_title text
)

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 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
)

Question: provide the number of patients whose discharge location is short term hospital and admission year is before 2198

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.discharge_location = "SHORT TERM HOSPITAL" AND demographic.admityear < "2198"

Question: what is admission time and drug dose of subject id 74032?

SQL:
SELECT demographic.admittime, prescriptions.drug_dose FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.subject_id = "74032"
Schema:
CREATE TABLE jobs (
    JOB_ID varchar(10),
    JOB_TITLE varchar(35),
    MIN_SALARY decimal(6,0),
    MAX_SALARY decimal(6,0)
)

CREATE TABLE countries (
    COUNTRY_ID varchar(2),
    COUNTRY_NAME varchar(40),
    REGION_ID decimal(10,0)
)

CREATE TABLE job_history (
    EMPLOYEE_ID decimal(6,0),
    START_DATE date,
    END_DATE date,
    JOB_ID varchar(10),
    DEPARTMENT_ID decimal(4,0)
)

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(4,0)
)

CREATE TABLE regions (
    REGION_ID decimal(5,0),
    REGION_NAME varchar(25)
)

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),
    LOCATION_ID decimal(4,0)
)

Question: 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, give me the comparison about the average of salary over the job_id , and group by attribute job_id, I want to order in descending by the JOB_ID please.

SQL:
SELECT JOB_ID, AVG(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY JOB_ID DESC
Schema:
CREATE TABLE table_51528 (
    "Feb 2010" text,
    "Mar 2010" text,
    "May 2010" real,
    "Jun 2010" real,
    "Jul 2010" real,
    "Aug 2010" real,
    "Sep 2010" real,
    "Oct 2010" real,
    "Nov 2010" real,
    "Dec 2010" real,
    "Jan 2011" real,
    "Feb 2011" real,
    "Mar 2011" real,
    "Apr 2011" real,
    "May 2011" real,
    "Jun 2011" real,
    "Jul 2011" real,
    "Aug 2011" real,
    "Sep 2011" real,
    "Oct 2011" real,
    "Nov 2011" real,
    "Dec 2011" real,
    "Jan 2012" real,
    "Feb 2012" real,
    "Mar 2012" real,
    "Apr 2012" real,
    "May 2012" real,
    "Jun 2012" real,
    "Jul 2012" real,
    "Aug 2012" real,
    "Sep 2012" real,
    "Oct 2012" real,
    "Nov 2012" real,
    "Dec 2012" real,
    "Jan 2013" real,
    "Feb 2013" real,
    "Mar 2013" real,
    "Apr 2013" real,
    "May 2013" real,
    "Jun 2013" real,
    "Jul 2013" real,
    "Aug 2013" real,
    "Sep 2013" real,
    "Oct 2013" real
)

Question: What is the highest Aug 2013 with a Nov 2011 smaller than 968, and a Jul 2012 with 31, and a Jun 2011 larger than 30?

SQL:
SELECT MAX("Aug 2013") FROM table_51528 WHERE "Nov 2011" < '968' AND "Jul 2012" = '31' AND "Jun 2011" > '30'
Schema:
CREATE TABLE table_24626 (
    "Round" real,
    "Date" text,
    "City and venue" text,
    "Winner" text,
    "Runner-up" text,
    "3rd placed" text,
    "4th placed" text,
    "Results" text
)

Question: How many rounds were on July 10?

SQL:
SELECT COUNT("Round") FROM table_24626 WHERE "Date" = 'July 10'
Schema:
CREATE TABLE table_203_268 (
    id number,
    "date" text,
    "name" text,
    "nationality" text,
    "tonnage\n(grt)" number,
    "fate" text
)

Question: what country lost the most ships to u-502 ?

SQL:
SELECT "nationality" FROM table_203_268 GROUP BY "nationality" ORDER BY COUNT("name") DESC LIMIT 1
Schema:
CREATE TABLE medication (
    medicationid number,
    patientunitstayid number,
    drugname text,
    dosage text,
    routeadmin text,
    drugstarttime time,
    drugstoptime time
)

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 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 treatment (
    treatmentid number,
    patientunitstayid number,
    treatmentname text,
    treatmenttime time
)

CREATE TABLE diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

CREATE TABLE lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime 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 microlab (
    microlabid number,
    patientunitstayid number,
    culturesite text,
    organism text,
    culturetakentime time
)

Question: how many hours have it been since the first time patient 027-140654 received procedures during their current hospital encounter?

SQL:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-140654' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
Schema:
CREATE TABLE table_15822 (
    "District" text,
    "Counties Represented" text,
    "Party" text,
    "First Elected" real,
    "Committee" text
)

Question: What district has counties represented by Baltimore county, a committee of health and government operations, and a first elected smaller than 2002?

SQL:
SELECT "District" FROM table_15822 WHERE "Counties Represented" = 'baltimore county' AND "Committee" = 'health and government operations' AND "First Elected" < '2002'
Schema:
CREATE TABLE table_203_333 (
    id number,
    "kilometers" number,
    "name" text,
    "location" text,
    "intersecting routes" text
)

Question: what is the number of routes that intersect highway 91 ?

SQL:
SELECT COUNT("intersecting routes") FROM table_203_333
Schema:
CREATE TABLE table_33617 (
    "Home team" text,
    "Home team score" text,
    "Away team" text,
    "Away team score" text,
    "Venue" text,
    "Crowd" real,
    "Date" text
)

Question: Who is the home side when the away side scores 11.15 (81)?

SQL:
SELECT "Home team" FROM table_33617 WHERE "Away team score" = '11.15 (81)'
Schema:
CREATE TABLE status (
    station_id INTEGER,
    bikes_available INTEGER,
    docks_available INTEGER,
    time TEXT
)

CREATE TABLE station (
    id INTEGER,
    name TEXT,
    lat NUMERIC,
    long NUMERIC,
    dock_count INTEGER,
    city TEXT,
    installation_date TEXT
)

CREATE TABLE weather (
    date TEXT,
    max_temperature_f INTEGER,
    mean_temperature_f INTEGER,
    min_temperature_f INTEGER,
    max_dew_point_f INTEGER,
    mean_dew_point_f INTEGER,
    min_dew_point_f INTEGER,
    max_humidity INTEGER,
    mean_humidity INTEGER,
    min_humidity INTEGER,
    max_sea_level_pressure_inches NUMERIC,
    mean_sea_level_pressure_inches NUMERIC,
    min_sea_level_pressure_inches NUMERIC,
    max_visibility_miles INTEGER,
    mean_visibility_miles INTEGER,
    min_visibility_miles INTEGER,
    max_wind_Speed_mph INTEGER,
    mean_wind_speed_mph INTEGER,
    max_gust_speed_mph INTEGER,
    precipitation_inches INTEGER,
    cloud_cover INTEGER,
    events TEXT,
    wind_dir_degrees INTEGER,
    zip_code INTEGER
)

CREATE TABLE trip (
    id INTEGER,
    duration INTEGER,
    start_date TEXT,
    start_station_name TEXT,
    start_station_id INTEGER,
    end_date TEXT,
    end_station_name TEXT,
    end_station_id INTEGER,
    bike_id INTEGER,
    subscription_type TEXT,
    zip_code INTEGER
)

Question: What is the frequency of the dates (bin into weekday interval) that had the top 5 cloud cover rates? You can draw me a bar chart for this purpose, and could you sort from low to high by the y-axis?

SQL:
SELECT date, COUNT(date) FROM weather ORDER BY COUNT(date)
Schema:
CREATE TABLE exhibition_record (
    Exhibition_ID int,
    Date text,
    Attendance int
)

CREATE TABLE artist (
    Artist_ID int,
    Name text,
    Country text,
    Year_Join int,
    Age int
)

CREATE TABLE exhibition (
    Exhibition_ID int,
    Year int,
    Theme text,
    Artist_ID int,
    Ticket_Price real
)

Question: Find dates and attendance for exhibitions that happened in 2004, show me the attendance by date with a bar chart.

SQL:
SELECT T1.Date, T1.Attendance FROM exhibition_record AS T1 JOIN exhibition AS T2 ON T1.Exhibition_ID = T2.Exhibition_ID WHERE T2.Year = 2004
Schema:
CREATE TABLE table_74082 (
    "Club" text,
    "Played" text,
    "Won" text,
    "Drawn" text,
    "Lost" text,
    "Points for" text,
    "Points against" text,
    "Tries for" text,
    "Points" text
)

Question: Which club lost exactly 7 matches?

SQL:
SELECT "Club" FROM table_74082 WHERE "Lost" = '7'
Schema:
CREATE TABLE table_name_32 (
    tie_no VARCHAR,
    date VARCHAR,
    home_team VARCHAR
)

Question: What is Tie no, when Date is '18 Nov 1989', and when Home Team is 'Doncaster Rovers'?

SQL:
SELECT tie_no FROM table_name_32 WHERE date = "18 nov 1989" AND home_team = "doncaster rovers"
Schema:
CREATE TABLE table_67152 (
    "Date" text,
    "Opponent" text,
    "Score" text,
    "Loss" text,
    "Attendance" real,
    "Record" text
)

Question: On August 22, how many people came to the game?

SQL:
SELECT "Attendance" FROM table_67152 WHERE "Date" = 'august 22'
Schema:
CREATE TABLE table_1342270_42 (
    first_elected INTEGER
)

Question: What is the latest year any of the incumbents were first elected?

SQL:
SELECT MAX(first_elected) FROM table_1342270_42
Schema:
CREATE TABLE table_20379 (
    "N\u00b0" real,
    "Television service" text,
    "Country" text,
    "Language" text,
    "Content" text,
    "DAR" text,
    "HDTV" text,
    "PPV" text,
    "Package/Option" text
)

Question: Name the ppv for sky famiglia and dar 16:9 for mtv dance

SQL:
SELECT "PPV" FROM table_20379 WHERE "Package/Option" = 'Sky Famiglia' AND "DAR" = '16:9' AND "Television service" = 'MTV Dance'
Schema:
CREATE TABLE protein (
    common_name text,
    protein_name text,
    divergence_from_human_lineage real,
    accession_number text,
    sequence_length real,
    sequence_identity_to_human_protein text,
    Institution_id text
)

CREATE TABLE building (
    building_id text,
    Name text,
    Street_address text,
    Years_as_tallest text,
    Height_feet int,
    Floors int
)

CREATE TABLE Institution (
    Institution_id text,
    Institution text,
    Location text,
    Founded real,
    Type text,
    Enrollment int,
    Team text,
    Primary_Conference text,
    building_id text
)

Question: Show institution names along with the number of proteins for each institution in a bar chart, and order by the y-axis in desc.

SQL:
SELECT Institution, COUNT(*) FROM Institution AS T1 JOIN protein AS T2 ON T1.Institution_id = T2.Institution_id GROUP BY T1.Institution_id ORDER BY COUNT(*) DESC
Schema:
CREATE TABLE table_48174 (
    "Res." text,
    "Record" text,
    "Opponent" text,
    "Method" text,
    "Event" text,
    "Round" real,
    "Time" text,
    "Location" text
)

Question: what is the record when the round is before 3 and the time si 4:59?

SQL:
SELECT "Record" FROM table_48174 WHERE "Round" < '3' AND "Time" = '4:59'
Schema:
CREATE TABLE Subjects (
    subject_id INTEGER,
    subject_name VARCHAR(120)
)

CREATE TABLE Students (
    student_id INTEGER,
    date_of_registration DATETIME,
    date_of_latest_logon DATETIME,
    login_name VARCHAR(40),
    password VARCHAR(10),
    personal_name VARCHAR(40),
    middle_name VARCHAR(40),
    family_name VARCHAR(40)
)

CREATE TABLE Course_Authors_and_Tutors (
    author_id INTEGER,
    author_tutor_ATB VARCHAR(3),
    login_name VARCHAR(40),
    password VARCHAR(40),
    personal_name VARCHAR(80),
    middle_name VARCHAR(80),
    family_name VARCHAR(80),
    gender_mf VARCHAR(1),
    address_line_1 VARCHAR(80)
)

CREATE TABLE Student_Course_Enrolment (
    registration_id INTEGER,
    student_id INTEGER,
    course_id INTEGER,
    date_of_enrolment DATETIME,
    date_of_completion DATETIME
)

CREATE TABLE Courses (
    course_id INTEGER,
    author_id INTEGER,
    subject_id INTEGER,
    course_name VARCHAR(120),
    course_description VARCHAR(255)
)

CREATE TABLE Student_Tests_Taken (
    registration_id INTEGER,
    date_test_taken DATETIME,
    test_result VARCHAR(255)
)

Question: A line chart for finding the number of the enrollment date for all the tests that have 'Pass' result.

SQL:
SELECT date_of_enrolment, COUNT(date_of_enrolment) FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Pass" GROUP BY date_of_enrolment
Schema:
CREATE TABLE table_name_43 (
    date VARCHAR,
    record VARCHAR
)

Question: When was 11-8 the record?

SQL:
SELECT date FROM table_name_43 WHERE record = "11-8"
Schema:
CREATE TABLE table_name_67 (
    share INTEGER,
    viewers__m_ VARCHAR,
    timeslot_rank VARCHAR
)

Question: What is the smallest share for a timeslot ranking less than 4 and fewer viewers than 8.78 million?

SQL:
SELECT MIN(share) FROM table_name_67 WHERE viewers__m_ < 8.78 AND timeslot_rank < 4
Schema:
CREATE TABLE table_41299 (
    "Date" text,
    "Tournament" text,
    "Surface" text,
    "Partnering" text,
    "Opponent in the final" text,
    "Score" text
)

Question: What surface was played on with a score of 6 4, 6 3 and on 4 May 1992?

SQL:
SELECT "Surface" FROM table_41299 WHERE "Score" = '6–4, 6–3' AND "Date" = '4 may 1992'
Schema:
CREATE TABLE table_47681 (
    "Rider" text,
    "Manufacturer" text,
    "Laps" text,
    "Time/Retired" text,
    "Grid" text
)

Question: WHAT IS THE MANUFACTURER WITH 24 LAPS, AND +1.965 TIME/RETIRED?

SQL:
SELECT "Manufacturer" FROM table_47681 WHERE "Laps" = '24' AND "Time/Retired" = '+1.965'
Schema:
CREATE TABLE table_203_498 (
    id number,
    "first issued" text,
    "design" text,
    "slogan" text,
    "serial format" text,
    "serials issued" text,
    "notes" text
)

Question: in what year was the last design of passenger baseplates for vehicle registration issued in vermont ?

SQL:
SELECT MAX("first issued") FROM table_203_498
Schema:
CREATE TABLE table_19500 (
    "Week" real,
    "Date" text,
    "Opponent" text,
    "Final score" text,
    "Team record" text,
    "Game site" text,
    "Attendance" real
)

Question: What day was the oppenent the detroit lions?

SQL:
SELECT "Date" FROM table_19500 WHERE "Opponent" = 'Detroit Lions'
Schema:
CREATE TABLE gas_station (
    Station_ID int,
    Open_Year int,
    Location text,
    Manager_Name text,
    Vice_Manager_Name text,
    Representative_Name text
)

CREATE TABLE company (
    Company_ID int,
    Rank int,
    Company text,
    Headquarters text,
    Main_Industry text,
    Sales_billion real,
    Profits_billion real,
    Assets_billion real,
    Market_Value real
)

CREATE TABLE station_company (
    Station_ID int,
    Company_ID int,
    Rank_of_the_Year int
)

Question: What is the market value of every comapny in the banking industry ordered by sales and profits? Return a bar chart.

SQL:
SELECT Company, Market_Value FROM company WHERE Main_Industry = 'Banking' ORDER BY Sales_billion, Profits_billion