VishalCh/book-train huggingface dataset:
Schema:
CREATE TABLE intakeoutput (
    intakeoutputid number,
    patientunitstayid number,
    cellpath text,
    celllabel text,
    cellvaluenumeric number,
    intakeoutputtime time
)

CREATE TABLE allergy (
    allergyid number,
    patientunitstayid number,
    drugname text,
    allergyname text,
    allergytime 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 cost (
    costid number,
    uniquepid text,
    patienthealthsystemstayid number,
    eventtype text,
    eventid number,
    chargetime time,
    cost number
)

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

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 microlab (
    microlabid number,
    patientunitstayid number,
    culturesite text,
    organism text,
    culturetakentime 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
)

Question: has patient 029-584 ever had a medication prescribed the last year?

SQL:
SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '029-584')) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
Schema:
CREATE TABLE table_9828 (
    "Model number" text,
    "sSpec number" text,
    "Frequency" text,
    "GPU frequency" text,
    "L2 cache" text,
    "I/O bus" text,
    "Memory" text,
    "Voltage" text,
    "Socket" text,
    "Release date" text,
    "Part number(s)" text
)

Question: What is Socket, when Part Number(s) is au80610003495aa?

SQL:
SELECT "Socket" FROM table_9828 WHERE "Part number(s)" = 'au80610003495aa'
Schema:
CREATE TABLE table_name_24 (
    to_par VARCHAR,
    year VARCHAR
)

Question: Which To par has a Year of 1994?

SQL:
SELECT to_par FROM table_name_24 WHERE year = 1994
Schema:
CREATE TABLE stadium (
    ID int,
    name text,
    Capacity int,
    City text,
    Country text,
    Opening_year int
)

CREATE TABLE event (
    ID int,
    Name text,
    Stadium_ID int,
    Year text
)

CREATE TABLE swimmer (
    ID int,
    name text,
    Nationality text,
    meter_100 real,
    meter_200 text,
    meter_300 text,
    meter_400 text,
    meter_500 text,
    meter_600 text,
    meter_700 text,
    Time text
)

CREATE TABLE record (
    ID int,
    Result text,
    Swimmer_ID int,
    Event_ID int
)

Question: Draw a bar chart about the distribution of meter_700 and ID , and rank meter_700 in desc order.

SQL:
SELECT meter_700, ID FROM swimmer ORDER BY meter_700 DESC
Schema:
CREATE TABLE table_name_36 (
    year VARCHAR,
    championship VARCHAR
)

Question: Which year was the peter jackson classic?

SQL:
SELECT year FROM table_name_36 WHERE championship = "peter jackson classic"
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 diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

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

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

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 intakeoutput (
    intakeoutputid number,
    patientunitstayid number,
    cellpath text,
    celllabel text,
    cellvaluenumeric number,
    intakeoutputtime 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 allergy (
    allergyid number,
    patientunitstayid number,
    drugname text,
    allergyname text,
    allergytime time
)

Question: what are the procedures that are the top four most commonly received?

SQL:
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 4
Schema:
CREATE TABLE table_name_27 (
    district VARCHAR,
    constituency_number VARCHAR
)

Question: What district has a constituency of 60?

SQL:
SELECT district FROM table_name_27 WHERE constituency_number = "60"
Schema:
CREATE TABLE table_14553 (
    "Year" real,
    "Entrant" text,
    "Chassis" text,
    "Engine" text,
    "Points" real
)

Question: When were there less than 1 point with a cosworth v8 engine in jolly club switzerland?

SQL:
SELECT "Year" FROM table_14553 WHERE "Points" < '1' AND "Engine" = 'cosworth v8' AND "Entrant" = 'jolly club switzerland'
Schema:
CREATE TABLE table_20718 (
    "Institution" text,
    "Location" text,
    "Team Nickname" text,
    "Joined TSCHL" real,
    "Home Arena" text,
    "Capacity" real,
    "Team Website" text
)

Question: For the flyers, what's the minimum capacity?

SQL:
SELECT MIN("Capacity") FROM table_20718 WHERE "Team Nickname" = 'Flyers'
Schema:
CREATE TABLE countries (
    COUNTRY_ID varchar(2),
    COUNTRY_NAME varchar(40),
    REGION_ID decimal(10,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 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 job_history (
    EMPLOYEE_ID decimal(6,0),
    START_DATE date,
    END_DATE date,
    JOB_ID varchar(10),
    DEPARTMENT_ID decimal(4,0)
)

CREATE TABLE jobs (
    JOB_ID varchar(10),
    JOB_TITLE varchar(35),
    MIN_SALARY decimal(6,0),
    MAX_SALARY decimal(6,0)
)

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

CREATE TABLE departments (
    DEPARTMENT_ID decimal(4,0),
    DEPARTMENT_NAME varchar(30),
    MANAGER_ID decimal(6,0),
    LOCATION_ID decimal(4,0)
)

Question: You can return a bar chart with employees' first names and their salaries, display by the y axis from high to low.

SQL:
SELECT FIRST_NAME, SALARY FROM employees ORDER BY SALARY DESC
Schema:
CREATE TABLE table_23292220_17 (
    scores VARCHAR,
    seans_team VARCHAR
)

Question: Name the scores for chris ramsey and carol vorderman

SQL:
SELECT scores FROM table_23292220_17 WHERE seans_team = "Chris Ramsey and Carol Vorderman"
Schema:
CREATE TABLE table_name_86 (
    games VARCHAR,
    tied VARCHAR
)

Question: What is the number of games for the season with 10 ties?

SQL:
SELECT games FROM table_name_86 WHERE tied = 10
Schema:
CREATE TABLE table_name_9 (
    year VARCHAR,
    event VARCHAR,
    position VARCHAR
)

Question: What year did she place 8th in the junior race?

SQL:
SELECT year FROM table_name_9 WHERE event = "junior race" AND position = "8th"
Schema:
CREATE TABLE Ref_Characteristic_Types (
    characteristic_type_code VARCHAR(15),
    characteristic_type_description VARCHAR(80)
)

CREATE TABLE Products (
    product_id INTEGER,
    color_code VARCHAR(15),
    product_category_code VARCHAR(15),
    product_name VARCHAR(80),
    typical_buying_price VARCHAR(20),
    typical_selling_price VARCHAR(20),
    product_description VARCHAR(255),
    other_product_details VARCHAR(255)
)

CREATE TABLE Product_Characteristics (
    product_id INTEGER,
    characteristic_id INTEGER,
    product_characteristic_value VARCHAR(50)
)

CREATE TABLE Characteristics (
    characteristic_id INTEGER,
    characteristic_type_code VARCHAR(15),
    characteristic_data_type VARCHAR(10),
    characteristic_name VARCHAR(80),
    other_characteristic_details VARCHAR(255)
)

CREATE TABLE Ref_Colors (
    color_code VARCHAR(15),
    color_description VARCHAR(80)
)

CREATE TABLE Ref_Product_Categories (
    product_category_code VARCHAR(15),
    product_category_description VARCHAR(80),
    unit_of_measure VARCHAR(20)
)

Question: A bar chart for what are the number of the descriptions of the categories that products with product descriptions that contain the letter t are in?, and rank y-axis in ascending order.

SQL:
SELECT product_category_description, COUNT(product_category_description) FROM Ref_Product_Categories AS T1 JOIN Products AS T2 ON T1.product_category_code = T2.product_category_code WHERE T2.product_description LIKE '%t%' GROUP BY product_category_description ORDER BY COUNT(product_category_description)
Schema:
CREATE TABLE table_56530 (
    "Year" text,
    "Starts" real,
    "Cuts made" real,
    "Wins" real,
    "Top 10" real,
    "Top 25" real,
    "Earnings ($)" real,
    "Money list rank" text
)

Question: What is the smallest Earnings that has a Money list rank of 6 and Starts smaller than 22?

SQL:
SELECT MIN("Earnings ($)") FROM table_56530 WHERE "Money list rank" = '6' AND "Starts" < '22'
Schema:
CREATE TABLE table_8509 (
    "White" text,
    "Black" text,
    "Year" real,
    "Result" text,
    "Moves" real,
    "Tournament" text,
    "Opening" text
)

Question: What year had 32 moves?

SQL:
SELECT SUM("Year") FROM table_8509 WHERE "Moves" = '32'
Schema:
CREATE TABLE table_204_343 (
    id number,
    "nation" text,
    "model" text,
    "length" text,
    "barrel length" text,
    "weight" text
)

Question: how long was the m1894 rifle 's barrel ?

SQL:
SELECT "barrel length" FROM table_204_343 WHERE "model" = 'm1894 rifle'
Schema:
CREATE TABLE table_name_65 (
    att INTEGER,
    yards VARCHAR,
    long VARCHAR
)

Question: How many Atts that have Yards of 43 and a Long larger than 43?

SQL:
SELECT SUM(att) FROM table_name_65 WHERE yards = 43 AND long > 43
Schema:
CREATE TABLE table_25220821_4 (
    mon_31_may VARCHAR,
    rank VARCHAR
)

Question: How many times are listed for 31 May for the rider ranked 5?

SQL:
SELECT COUNT(mon_31_may) FROM table_25220821_4 WHERE rank = 5
Schema:
CREATE TABLE train (
    id int,
    train_number int,
    name text,
    origin text,
    destination text,
    time text,
    interval text
)

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 route (
    train_id int,
    station_id int
)

CREATE TABLE station (
    id int,
    network_name text,
    services text,
    local_authority text
)

Question: Plot how many name by grouped by name as a bar graph, and sort by the total number in descending.

SQL:
SELECT name, COUNT(name) FROM train GROUP BY name ORDER BY COUNT(name) DESC
Schema:
CREATE TABLE table_56316 (
    "Driver" text,
    "Constructor" text,
    "Laps" real,
    "Time/Retired" text,
    "Grid" real
)

Question: Which constructor has a Time/Retired of +37.311?

SQL:
SELECT "Constructor" FROM table_56316 WHERE "Time/Retired" = '+37.311'
Schema:
CREATE TABLE table_name_91 (
    tournament VARCHAR
)

Question: What is the 2007 result when the 2010 result was 2r, at the US Open?

SQL:
SELECT 2007 FROM table_name_91 WHERE 2010 = "2r" AND tournament = "us open"
Schema:
CREATE TABLE table_22277 (
    "Departure" text,
    "Going to" text,
    "Calling at" text,
    "Arrival" text,
    "Operator" text
)

Question: when does the train arriving at bourne at 11.45 departure

SQL:
SELECT "Departure" FROM table_22277 WHERE "Going to" = 'Bourne' AND "Arrival" = '11.45'
Schema:
CREATE TABLE table_name_58 (
    time_retired VARCHAR,
    grid VARCHAR,
    driver VARCHAR
)

Question: Which Time/Retired has a Grid smaller than 3, and a Driver of mika h kkinen?

SQL:
SELECT time_retired FROM table_name_58 WHERE grid < 3 AND driver = "mika häkkinen"
Schema:
CREATE TABLE table_name_4 (
    attendance INTEGER,
    date VARCHAR
)

Question: What was the higest attendance on November 9, 1958?

SQL:
SELECT MAX(attendance) FROM table_name_4 WHERE date = "november 9, 1958"
Schema:
CREATE TABLE table_78521 (
    "Team" text,
    "Games Played" real,
    "Wins" real,
    "Losses" real,
    "Ties" real,
    "Goals For" real,
    "Goals Against" real
)

Question: How many losses did the team with 22 goals for andmore than 8 games played have?

SQL:
SELECT COUNT("Losses") FROM table_78521 WHERE "Goals For" = '22' AND "Games Played" > '8'
Schema:
CREATE TABLE table_2930244_3 (
    number_of_major_hurricanes INTEGER
)

Question: What is the largest overall number of major hurricanes?

SQL:
SELECT MAX(number_of_major_hurricanes) FROM table_2930244_3
Schema:
CREATE TABLE procedures (
    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 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
)

CREATE TABLE diagnoses (
    subject_id text,
    hadm_id text,
    icd9_code text,
    short_title text,
    long_title text
)

Question: count the number of patients whose primary disease is pneumonia;human immunodefiency virus;rule out tuberculosis and year of death is less than or equal to 2168?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "PNEUMONIA;HUMAN IMMUNODEFIENCY VIRUS;RULE OUT TUBERCULOSIS" AND demographic.dod_year <= "2168.0"

Question: what is discharge time of subject id 6983?

SQL:
SELECT demographic.dischtime FROM demographic WHERE demographic.subject_id = "6983"

Question: count the number of patients whose primary disease is morbid obesity/sda and drug name is soln.?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "MORBID OBESITY/SDA" AND prescriptions.drug = "Soln."
Schema:
CREATE TABLE table_41531 (
    "Player" text,
    "Position" text,
    "Date of Birth (Age)" text,
    "Caps" text,
    "Province / Club" text
)

Question: What is Position, when Caps is Example, and When Player is Shane Kelly?

SQL:
SELECT "Position" FROM table_41531 WHERE "Caps" = 'example' AND "Player" = 'shane kelly'
Schema:
CREATE TABLE table_name_97 (
    proto_austronesian VARCHAR,
    proto_oceanic VARCHAR
)

Question: Which Proto-Austronesian has a Proto-Oceanic of *lima?

SQL:
SELECT proto_austronesian FROM table_name_97 WHERE proto_oceanic = "*lima"
Schema:
CREATE TABLE table_60349 (
    "Tie no" text,
    "Home team" text,
    "Score" text,
    "Away team" text,
    "Date" text
)

Question: What is the Away team at the Wolverhampton Wanderers Home game with a Score of 2 0?

SQL:
SELECT "Away team" FROM table_60349 WHERE "Score" = '2–0' AND "Home team" = 'wolverhampton wanderers'
Schema:
CREATE TABLE table_name_19 (
    res VARCHAR,
    opponent VARCHAR
)

Question: The match against Oleg Taktarov had what result?

SQL:
SELECT res FROM table_name_19 WHERE opponent = "oleg taktarov"
Schema:
CREATE TABLE diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

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

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 (
    allergyid number,
    patientunitstayid number,
    drugname text,
    allergyname text,
    allergytime time
)

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

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

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

Question: what is the four most frequently ordered procedure for a patient with an age 40s?

SQL:
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 40 AND 49) GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 4
Schema:
CREATE TABLE table_55779 (
    "Entrant" text,
    "Constructor" text,
    "Chassis" text,
    "Engine" text,
    "Tyres" text,
    "Driver" text,
    "Rounds" text
)

Question: What was the featured in Engine through rounds 10-13?

SQL:
SELECT "Engine" FROM table_55779 WHERE "Rounds" = '10-13'
Schema:
CREATE TABLE table_67113 (
    "School" text,
    "Team" text,
    "Division Record" text,
    "Overall Record" text,
    "Season Outcome" text
)

Question: What was Laurel's division record?

SQL:
SELECT "Division Record" FROM table_67113 WHERE "School" = 'laurel'
Schema:
CREATE TABLE table_name_91 (
    games INTEGER,
    name VARCHAR,
    points VARCHAR
)

Question: What is the lowest Games, when Name is Jeremiah Massey, and when Points is less than 340?

SQL:
SELECT MIN(games) FROM table_name_91 WHERE name = "jeremiah massey" AND points < 340
Schema:
CREATE TABLE table_30030227_1 (
    written_by VARCHAR,
    directed_by VARCHAR
)

Question: How many people wrote the episode directed by Arvin Brown?

SQL:
SELECT COUNT(written_by) FROM table_30030227_1 WHERE directed_by = "Arvin Brown"
Schema:
CREATE TABLE table_70406 (
    "Year" real,
    "Entrant" text,
    "Chassis" text,
    "Engine" text,
    "Points" real
)

Question: How many years was ensign n180b a Chassis with 4 points?

SQL:
SELECT SUM("Year") FROM table_70406 WHERE "Points" = '4' AND "Chassis" = 'ensign n180b'
Schema:
CREATE TABLE table_75827 (
    "Season" text,
    "Competition" text,
    "Round" text,
    "Opponent" text,
    "Home" text,
    "Away" text,
    "Series" text
)

Question: Which Opponent has an Away of 1 1, and a Home of 3 3?

SQL:
SELECT "Opponent" FROM table_75827 WHERE "Away" = '1–1' AND "Home" = '3–3'
Schema:
CREATE TABLE table_name_49 (
    venue VARCHAR,
    competition VARCHAR
)

Question: What was the venue that had a friendly match competition?

SQL:
SELECT venue FROM table_name_49 WHERE competition = "friendly match"