VishalCh/book-train huggingface dataset:
Schema:
CREATE TABLE table_8680 (
    "Position" real,
    "Club" text,
    "Played" real,
    "Points" real,
    "Wins" real,
    "Draws" real,
    "Losses" real,
    "Goals for" real,
    "Goals against" real,
    "Goal Difference" real
)

Question: How many wins happened when there were fewer than 2 draws?

SQL:
SELECT SUM("Wins") FROM table_8680 WHERE "Draws" < '2'
Schema:
CREATE TABLE table_10749367_3 (
    _number INTEGER,
    air_date VARCHAR
)

Question: What episode aired on 18 April 2007?

SQL:
SELECT MIN(_number) FROM table_10749367_3 WHERE air_date = "18 April 2007"
Schema:
CREATE TABLE table_name_62 (
    runner_up VARCHAR,
    name VARCHAR,
    year VARCHAR
)

Question: Who was runner-up in the 2006 Pacific Life Open?

SQL:
SELECT runner_up FROM table_name_62 WHERE name = "pacific life open" AND year = "2006"
Schema:
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 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 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 lab (
    subject_id text,
    hadm_id text,
    itemid text,
    charttime text,
    flag text,
    value_unit text,
    label text,
    fluid text
)

Question: what is death status of subject id 3343?

SQL:
SELECT demographic.expire_flag FROM demographic WHERE demographic.subject_id = "3343"

Question: what is age and procedure short title of subject id 2560?

SQL:
SELECT demographic.age, procedures.short_title FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.subject_id = "2560"
Schema:
CREATE TABLE table_name_25 (
    points_for INTEGER,
    record VARCHAR,
    points_against VARCHAR
)

Question: What is the highest Points when the record was 12 2, and the Points Against are larger than 6?

SQL:
SELECT MAX(points_for) FROM table_name_25 WHERE record = "12–2" AND points_against > 6
Schema:
CREATE TABLE genre (
    g_name varchar2(20),
    rating varchar2(10),
    most_popular_in varchar2(50)
)

CREATE TABLE artist (
    artist_name varchar2(50),
    country varchar2(20),
    gender varchar2(20),
    preferred_genre varchar2(50)
)

CREATE TABLE song (
    song_name varchar2(50),
    artist_name varchar2(50),
    country varchar2(20),
    f_id number(10),
    genre_is varchar2(20),
    rating number(10),
    languages varchar2(20),
    releasedate Date,
    resolution number(10)
)

CREATE TABLE files (
    f_id number(10),
    artist_name varchar2(50),
    file_size varchar2(20),
    duration varchar2(20),
    formats varchar2(20)
)

Question: Show me mean rating by languages in a histogram, sort X from high to low order.

SQL:
SELECT languages, AVG(rating) FROM song GROUP BY languages ORDER BY languages DESC
Schema:
CREATE TABLE table_17347 (
    "#" real,
    "Date" text,
    "Visitor" text,
    "Score" text,
    "Home" text,
    "Leading scorer" text,
    "Attendance" text,
    "Record" text,
    "Streak" text
)

Question: what's the score where record is 35 33

SQL:
SELECT "Score" FROM table_17347 WHERE "Record" = '35–33'
Schema:
CREATE TABLE table_name_51 (
    loss VARCHAR,
    record VARCHAR
)

Question: What was the score of the game that put the team at 27-32?

SQL:
SELECT loss FROM table_name_51 WHERE record = "27-32"
Schema:
CREATE TABLE table_name_37 (
    to_par VARCHAR,
    place VARCHAR,
    player VARCHAR
)

Question: What was the To par for bill britton when he placed t7?

SQL:
SELECT to_par FROM table_name_37 WHERE place = "t7" AND player = "bill britton"
Schema:
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 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 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: how many patients are admitted under urgency and followed the procedure colonoscopy?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "URGENT" AND procedures.short_title = "Colonoscopy"

Question: how many patients were diagnosed for laparoscopic surgical procedure converted to open procedure and the death status is 0?

SQL:
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 = "Laparoscopic surgical procedure converted to open procedure"

Question: specify the age of patient paul edwards

SQL:
SELECT demographic.age FROM demographic WHERE demographic.name = "Paul Edwards"

Question: what is the number of patients whose admission type is elective and procedure long title is laparoscopic lysis of peritoneal adhesions?

SQL:
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 = "Laparoscopic lysis of peritoneal adhesions"
Schema:
CREATE TABLE table_name_64 (
    record VARCHAR,
    time VARCHAR,
    opponent VARCHAR
)

Question: What's the record that had an opponent of Krzysztof Soszynski and a time of 4:00?

SQL:
SELECT record FROM table_name_64 WHERE time = "4:00" AND opponent = "krzysztof soszynski"
Schema:
CREATE TABLE table_name_35 (
    status VARCHAR,
    date VARCHAR
)

Question: What's the status on 16/12/1995?

SQL:
SELECT status FROM table_name_35 WHERE date = "16/12/1995"
Schema:
CREATE TABLE table_56036 (
    "Home team" text,
    "Home team score" text,
    "Away team" text,
    "Away team score" text,
    "Venue" text,
    "Crowd" real,
    "Date" text
)

Question: What was the crowd size when the visiting team scored 23.18 (156)?

SQL:
SELECT COUNT("Crowd") FROM table_56036 WHERE "Away team score" = '23.18 (156)'
Schema:
CREATE TABLE table_name_77 (
    frequency_mhz INTEGER,
    call_sign VARCHAR
)

Question: what is the highest frequency mhz with the call sign w292cu?

SQL:
SELECT MAX(frequency_mhz) FROM table_name_77 WHERE call_sign = "w292cu"
Schema:
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 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 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 diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

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

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

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

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

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

Question: how many patients were prescribed 2 ml : metoclopramide hcl 5 mg/ml inj soln within 2 months since 2103 after being diagnosed with copd - no limitations?

SQL:
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'copd - no limitations' AND STRFTIME('%y', diagnosis.diagnosistime) >= '2103') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = '2 ml : metoclopramide hcl 5 mg/ml inj soln' AND STRFTIME('%y', medication.drugstarttime) >= '2103') AS t2 WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')
Schema:
CREATE TABLE station (
    id int,
    network_name text,
    services text,
    local_authority text
)

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,
    destination text,
    time text,
    interval text
)

Question: What is the average high temperature for each day of week Plot them as bar chart, rank Y-axis in desc order.

SQL:
SELECT day_of_week, AVG(high_temperature) FROM weekly_weather GROUP BY day_of_week ORDER BY AVG(high_temperature) DESC
Schema:
CREATE TABLE table_name_14 (
    production_code INTEGER,
    series__number VARCHAR
)

Question: What was the lowest production code value in series #10?

SQL:
SELECT MIN(production_code) FROM table_name_14 WHERE series__number = 10
Schema:
CREATE TABLE table_56683 (
    "Date" text,
    "Visitor" text,
    "Score" text,
    "Home" text,
    "Decision" text,
    "Attendance" real,
    "Record" text
)

Question: What is the total of attendance with a Record of 5-9-0?

SQL:
SELECT SUM("Attendance") FROM table_56683 WHERE "Record" = '5-9-0'
Schema:
CREATE TABLE table_78184 (
    "Driver" text,
    "Constructor" text,
    "Laps" real,
    "Time/Retired" text,
    "Grid" real
)

Question: What is the low lap total for a grid larger than 16 and has a Time/Retired of + 3:27.3?

SQL:
SELECT MIN("Laps") FROM table_78184 WHERE "Time/Retired" = '+ 3:27.3' AND "Grid" > '16'
Schema:
CREATE TABLE table_203_778 (
    id number,
    "representative" text,
    "title" text,
    "presentation\nof credentials" text,
    "termination\nof mission" text,
    "appointed by" text
)

Question: which reps were only appointed by franklin pierce ?

SQL:
SELECT "representative" FROM table_203_778 WHERE "appointed by" = 'franklin pierce'
Schema:
CREATE TABLE table_52977 (
    "Season" text,
    "UEFA Season" text,
    "Coeff" text,
    "Ranking" real,
    "Champions" text,
    "Runner-up" text,
    "3rd place" text,
    "Cup winner" text,
    "Cup runner-up" text
)

Question: Which Champion has a Coeff of 1.000?

SQL:
SELECT "Champions" FROM table_52977 WHERE "Coeff" = '1.000'
Schema:
CREATE TABLE table_62868 (
    "Team 1" text,
    "Agg." text,
    "Team 2" text,
    "1st leg" text,
    "2nd leg" text
)

Question: What is the 2nd leg in match with team 2 of Teram?

SQL:
SELECT "2nd leg" FROM table_62868 WHERE "Team 2" = 'teram'