VishalCh/book-train huggingface dataset:
Schema:
CREATE TABLE table_name_28 (
    railway_number_s_ VARCHAR,
    class VARCHAR
)

Question: What's the railway number of a D(rebuild) class?

SQL:
SELECT railway_number_s_ FROM table_name_28 WHERE class = "d(rebuild)"
Schema:
CREATE TABLE table_train_169 (
    "id" int,
    "leukocytes" int,
    "hemoglobin_a1c_hba1c" float,
    "urine_albumin_excretion" int,
    "estimated_glomerular_filtration_rate_egfr" int,
    "glucola_beverage_gct" int,
    "age" float,
    "NOUSE" float
)

Question: screening egfr < 60 ml / min / 1.73 m2

SQL:
SELECT * FROM table_train_169 WHERE estimated_glomerular_filtration_rate_egfr < 60
Schema:
CREATE TABLE cost (
    costid number,
    uniquepid text,
    patienthealthsystemstayid number,
    eventtype text,
    eventid number,
    chargetime time,
    cost number
)

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 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 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 medication (
    medicationid number,
    patientunitstayid number,
    drugname text,
    dosage text,
    routeadmin text,
    drugstarttime time,
    drugstoptime 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
)

Question: what is the name of the drug that patient 002-41152 has been prescribed two or more times last month?

SQL:
SELECT t1.drugname FROM (SELECT medication.drugname, COUNT(medication.drugstarttime) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-41152')) AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') GROUP BY medication.drugname) AS t1 WHERE t1.c1 >= 2
Schema:
CREATE TABLE table_10468 (
    "Independent" text,
    "Lost" real,
    "Tied" real,
    "Pct." real,
    "Years" real,
    "Total Games" real
)

Question: What is the average number lost when the PCT is more than 0.7334 and the total number of games is larger than 48?

SQL:
SELECT AVG("Lost") FROM table_10468 WHERE "Pct." > '0.7334' AND "Total Games" > '48'
Schema:
CREATE TABLE microlab (
    microlabid number,
    patientunitstayid number,
    culturesite text,
    organism text,
    culturetakentime 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 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 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 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 lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime time
)

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

Question: how many times did patient 010-6098 since 128 months ago receive crystalloids?

SQL:
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-6098')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'crystalloids' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-128 month')
Schema:
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 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
)

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

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

Question: how much does the minimum hospital cost including a procedure called hypotonic fluid administration - d5w until 1 year ago?

SQL:
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'hypotonic fluid administration - d5w')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
Schema:
CREATE TABLE table_54361 (
    "Candidate" text,
    "Contributions" real,
    "Loans Received" real,
    "All Receipts" real,
    "Operating Expenditures" real,
    "All Disbursements" real
)

Question: How much is the lowest Operating Expenditures when Contributions are more than 8,245,241?

SQL:
SELECT MIN("Operating Expenditures") FROM table_54361 WHERE "Contributions" > '8,245,241'
Schema:
CREATE TABLE table_70723 (
    "Rank" real,
    "Nation" text,
    "Gold" real,
    "Silver" real,
    "Bronze" real,
    "Total" real
)

Question: How many gold medals does the country ranked higher than 2 with more than 8 bronze have?

SQL:
SELECT SUM("Gold") FROM table_70723 WHERE "Rank" < '2' AND "Bronze" > '8'
Schema:
CREATE TABLE table_203_873 (
    id number,
    "model name" text,
    "length" text,
    "width" text,
    "height" text,
    "riders" number,
    "capacity" number,
    "description" text,
    "portable" text,
    "notes" number
)

Question: total number of models created .

SQL:
SELECT COUNT(DISTINCT "model name") FROM table_203_873
Schema:
CREATE TABLE table_name_7 (
    engine VARCHAR,
    year INTEGER
)

Question: Which engine has a Year larger than 1969?

SQL:
SELECT engine FROM table_name_7 WHERE year > 1969
Schema:
CREATE TABLE table_53738 (
    "Home team" text,
    "Home team score" text,
    "Away team" text,
    "Away team score" text,
    "Venue" text,
    "Crowd" real,
    "Date" text
)

Question: Who was the home team when the away team was Footscray?

SQL:
SELECT "Home team" FROM table_53738 WHERE "Away team" = 'footscray'
Schema:
CREATE TABLE table_name_59 (
    position VARCHAR,
    years_for_jazz VARCHAR
)

Question: Which position was active in Jazz in 2002-03?

SQL:
SELECT position FROM table_name_59 WHERE years_for_jazz = "2002-03"
Schema:
CREATE TABLE diagnosis (
    diagnosisid number,
    patientunitstayid number,
    diagnosisname text,
    diagnosistime time,
    icd9code text
)

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 medication (
    medicationid number,
    patientunitstayid number,
    drugname text,
    dosage text,
    routeadmin text,
    drugstarttime time,
    drugstoptime time
)

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

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

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 vitalperiodic (
    vitalperiodicid number,
    patientunitstayid number,
    temperature number,
    sao2 number,
    heartrate number,
    respiration number,
    systemicsystolic number,
    systemicdiastolic number,
    systemicmean number,
    observationtime time
)

Question: on this month/27 what was the respiration minimum value of patient 005-87465?

SQL:
SELECT MIN(vitalperiodic.respiration) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-87465')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', vitalperiodic.observationtime) = '27'
Schema:
CREATE TABLE table_name_43 (
    actor VARCHAR,
    year VARCHAR
)

Question: Which actor won in 1966?

SQL:
SELECT actor FROM table_name_43 WHERE year = 1966
Schema:
CREATE TABLE table_3703 (
    "Team" text,
    "Outgoing manager" text,
    "Manner of departure" text,
    "Date of vacancy" text,
    "Replaced by" text,
    "Date of appointment" text
)

Question: For outgoing manager is alberto malesani mention all the applicable replaced by person

SQL:
SELECT "Replaced by" FROM table_3703 WHERE "Outgoing manager" = 'Alberto Malesani'
Schema:
CREATE TABLE table_18703133_6 (
    losses VARCHAR,
    team VARCHAR
)

Question: How many losses are there for team tembetary?

SQL:
SELECT losses FROM table_18703133_6 WHERE team = "Tembetary"
Schema:
CREATE TABLE table_1053802_1 (
    main_presenters VARCHAR,
    region_country VARCHAR
)

Question: What is the main presenter of bulgaria?

SQL:
SELECT main_presenters FROM table_1053802_1 WHERE region_country = "Bulgaria"
Schema:
CREATE TABLE table_28715942_5 (
    original_artist VARCHAR,
    vocal_percussionist VARCHAR
)

Question: What is the original artist when the vocal percussionist is Alexei Kalveks?

SQL:
SELECT original_artist FROM table_28715942_5 WHERE vocal_percussionist = "Alexei Kalveks"
Schema:
CREATE TABLE Ref_Document_Types (
    Document_Type_Code CHAR(15),
    Document_Type_Name VARCHAR(255),
    Document_Type_Description VARCHAR(255)
)

CREATE TABLE All_Documents (
    Document_ID INTEGER,
    Date_Stored DATETIME,
    Document_Type_Code CHAR(15),
    Document_Name CHAR(255),
    Document_Description CHAR(255),
    Other_Details VARCHAR(255)
)

CREATE TABLE Employees (
    Employee_ID INTEGER,
    Role_Code CHAR(15),
    Employee_Name VARCHAR(255),
    Gender_MFU CHAR(1),
    Date_of_Birth DATETIME,
    Other_Details VARCHAR(255)
)

CREATE TABLE Ref_Locations (
    Location_Code CHAR(15),
    Location_Name VARCHAR(255),
    Location_Description VARCHAR(255)
)

CREATE TABLE Ref_Calendar (
    Calendar_Date DATETIME,
    Day_Number INTEGER
)

CREATE TABLE Roles (
    Role_Code CHAR(15),
    Role_Name VARCHAR(255),
    Role_Description VARCHAR(255)
)

CREATE TABLE Documents_to_be_Destroyed (
    Document_ID INTEGER,
    Destruction_Authorised_by_Employee_ID INTEGER,
    Destroyed_by_Employee_ID INTEGER,
    Planned_Destruction_Date DATETIME,
    Actual_Destruction_Date DATETIME,
    Other_Details VARCHAR(255)
)

CREATE TABLE Document_Locations (
    Document_ID INTEGER,
    Location_Code CHAR(15),
    Date_in_Location_From DATETIME,
    Date_in_Locaton_To DATETIME
)

Question: How many documents in different ending date? Return a line chart grouping by ending date.

SQL:
SELECT Date_in_Locaton_To, COUNT(Date_in_Locaton_To) FROM Document_Locations GROUP BY Date_in_Locaton_To
Schema:
CREATE TABLE table_name_27 (
    total INTEGER,
    gold VARCHAR,
    bronze VARCHAR,
    nation VARCHAR
)

Question: What is the sum of all total medals with more than 2 bronze medals and more than 1 gold medal for the United States?

SQL:
SELECT SUM(total) FROM table_name_27 WHERE bronze > 2 AND nation = "united states" AND gold > 1
Schema:
CREATE TABLE table_70472 (
    "Date" text,
    "Tournament" text,
    "Winning score" text,
    "Margin of victory" text,
    "Runner(s)-up" text
)

Question: What was the winning score of the Buy.com Siouxland Open?

SQL:
SELECT "Winning score" FROM table_70472 WHERE "Tournament" = 'buy.com siouxland open'
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 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
)

Question: Provide me the number of patients born before 1846 who have an abnormal lab test status.

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "1846" AND lab.flag = "abnormal"
Schema:
CREATE TABLE table_59768 (
    "Year" real,
    "Pick" text,
    "Player" text,
    "Position" text,
    "Country" text,
    "Previous team (League)" text
)

Question: What is Country, when Previous Team (League) is 'Kingston Frontenacs ( OHL )', and when Player is 'Anthony Stewart Category:Articles with hCards'?

SQL:
SELECT "Country" FROM table_59768 WHERE "Previous team (League)" = 'kingston frontenacs ( ohl )' AND "Player" = 'anthony stewart category:articles with hcards'
Schema:
CREATE TABLE rating (
    rid number,
    mid number,
    stars number,
    ratingdate time
)

CREATE TABLE reviewer (
    rid number,
    name text
)

CREATE TABLE movie (
    mid number,
    title text,
    year number,
    director text
)

Question: Find the title and star rating of the movie that got the least rating star for each reviewer.

SQL:
SELECT T2.title, T1.rid, T1.stars, MIN(T1.stars) FROM rating AS T1 JOIN movie AS T2 ON T1.mid = T2.mid GROUP BY T1.rid
Schema:
CREATE TABLE ref_document_status (
    document_status_code text,
    document_status_description text
)

CREATE TABLE circulation_history (
    document_id number,
    draft_number number,
    copy_number number,
    employee_id number
)

CREATE TABLE documents (
    document_id number,
    document_status_code text,
    document_type_code text,
    shipping_agent_code text,
    receipt_date time,
    receipt_number text,
    other_details text
)

CREATE TABLE documents_mailed (
    document_id number,
    mailed_to_address_id number,
    mailing_date time
)

CREATE TABLE document_drafts (
    document_id number,
    draft_number number,
    draft_details text
)

CREATE TABLE roles (
    role_code text,
    role_description text
)

CREATE TABLE ref_shipping_agents (
    shipping_agent_code text,
    shipping_agent_name text,
    shipping_agent_description text
)

CREATE TABLE ref_document_types (
    document_type_code text,
    document_type_description text
)

CREATE TABLE addresses (
    address_id number,
    address_details text
)

CREATE TABLE employees (
    employee_id number,
    role_code text,
    employee_name text,
    other_details text
)

CREATE TABLE draft_copies (
    document_id number,
    draft_number number,
    copy_number number
)

Question: List roles that have more than one employee. List the role description and number of employees.

SQL:
SELECT roles.role_description, COUNT(employees.employee_id) FROM roles JOIN employees ON employees.role_code = roles.role_code GROUP BY employees.role_code HAVING COUNT(employees.employee_id) > 1
Schema:
CREATE TABLE table_66466 (
    "Sport" text,
    "Body" text,
    "Year" text,
    "Event type" text,
    "Location" text,
    "Nations" text
)

Question: What nations participated in 2007?

SQL:
SELECT "Nations" FROM table_66466 WHERE "Year" = '2007'
Schema:
CREATE TABLE table_34550 (
    "Rank" real,
    "Country" text,
    "International tourist arrivals (2012)" text,
    "International tourist arrivals (2011)" text,
    "Change (2011 to 2012)" text,
    "Change (2010 to 2011)" text
)

Question: How many tourists visited the country that had 2.5 million tourists in 2011?

SQL:
SELECT "International tourist arrivals (2012)" FROM table_34550 WHERE "International tourist arrivals (2011)" = '2.5 million'
Schema:
CREATE TABLE table_11219 (
    "Stage" text,
    "Winner" text,
    "General classification" text,
    "Points classification" text,
    "Trofeo Fast Team" text
)

Question: What stage did team Carrera Jeans-Tassoni have when Mario Cipollini won and Claudio Chiappucci had the points?

SQL:
SELECT "Stage" FROM table_11219 WHERE "Trofeo Fast Team" = 'carrera jeans-tassoni' AND "Winner" = 'mario cipollini' AND "Points classification" = 'claudio chiappucci'
Schema:
CREATE TABLE table_27597 (
    "Team" text,
    "Outgoing manager" text,
    "Manner of departure" text,
    "Date of vacancy" text,
    "Position in table" text,
    "Replaced by" text,
    "Date of appointment" text
)

Question: Name the replaced by for august 9

SQL:
SELECT "Replaced by" FROM table_27597 WHERE "Date of vacancy" = 'August 9' AND "Date of appointment" = 'August 9'
Schema:
CREATE TABLE table_name_81 (
    venue VARCHAR,
    date VARCHAR
)

Question: What venue was on 27 May 2000?

SQL:
SELECT venue FROM table_name_81 WHERE date = "27 may 2000"