VishalCh/book-train huggingface dataset:
Schema:
CREATE TABLE table_65693 (
    "School" text,
    "Location" text,
    "Mascot" text,
    "Enrollment" real,
    "IHSAA Class" text,
    "IHSAA Football Class" text,
    "County" text
)

Question: What school has the Lancers as their mascot?

SQL:
SELECT "Location" FROM table_65693 WHERE "Mascot" = 'lancers'
Schema:
CREATE TABLE table_60420 (
    "Tie no" text,
    "Home team" text,
    "Score" text,
    "Away team" text,
    "Date" text
)

Question: What was the tie number for the game with an away team of Hartlepool United?

SQL:
SELECT "Tie no" FROM table_60420 WHERE "Away team" = 'hartlepool united'
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 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 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 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 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: count the number of patients who had received vitamin k within 2 months after being diagnosed with bone fracture(s) - left lower extremity until 3 years ago.

SQL:
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'bone fracture(s) - left lower extremity' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-3 year')) AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'vitamin k' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-3 year')) AS t2 WHERE t1.diagnosistime < t2.treatmenttime AND DATETIME(t2.treatmenttime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')
Schema:
CREATE TABLE table_name_92 (
    round VARCHAR,
    race VARCHAR
)

Question: What is the round for the Int. Adac-Preis Der Tourenwagen Von Sachsen-Anhalt?

SQL:
SELECT round FROM table_name_92 WHERE race = "int. adac-preis der tourenwagen von sachsen-anhalt"
Schema:
CREATE TABLE table_203_606 (
    id number,
    "region" text,
    "rnd" number,
    "host" text,
    "venue" text,
    "city" text,
    "state" text
)

Question: total number of venues that hosted first and second round games .

SQL:
SELECT COUNT("venue") FROM table_203_606 WHERE "rnd" = 1 OR "rnd" = 2
Schema:
CREATE TABLE table_54219 (
    "Driver" text,
    "Constructor" text,
    "Laps" real,
    "Time/Retired" text,
    "Grid" real
)

Question: Which constructor has laps less than 100 and a time/retired +10 laps?

SQL:
SELECT "Constructor" FROM table_54219 WHERE "Laps" < '100' AND "Time/Retired" = '+10 laps'
Schema:
CREATE TABLE microlab (
    microlabid number,
    patientunitstayid number,
    culturesite text,
    organism text,
    culturetakentime 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 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 treatment (
    treatmentid number,
    patientunitstayid number,
    treatmentname text,
    treatmenttime 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
)

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

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
)

Question: what was the first time that patient 003-83 had an intake since 995 days ago?

SQL:
SELECT intakeoutput.intakeoutputtime FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-83')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-995 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
Schema:
CREATE TABLE table_22083044_2 (
    winning_team VARCHAR,
    circuit VARCHAR,
    fastest_lap VARCHAR
)

Question: What was the winning team where Tim Macrow won the fastest lap on Queensland Raceway circuit?

SQL:
SELECT winning_team FROM table_22083044_2 WHERE circuit = "Queensland Raceway" AND fastest_lap = "Tim Macrow"
Schema:
CREATE TABLE outputevents (
    row_id number,
    subject_id number,
    hadm_id number,
    icustay_id number,
    charttime time,
    itemid number,
    value number
)

CREATE TABLE procedures_icd (
    row_id number,
    subject_id number,
    hadm_id number,
    icd9_code text,
    charttime time
)

CREATE TABLE chartevents (
    row_id number,
    subject_id number,
    hadm_id number,
    icustay_id number,
    itemid number,
    charttime time,
    valuenum number,
    valueuom text
)

CREATE TABLE prescriptions (
    row_id number,
    subject_id number,
    hadm_id number,
    startdate time,
    enddate time,
    drug text,
    dose_val_rx text,
    dose_unit_rx text,
    route text
)

CREATE TABLE d_labitems (
    row_id number,
    itemid number,
    label text
)

CREATE TABLE diagnoses_icd (
    row_id number,
    subject_id number,
    hadm_id number,
    icd9_code text,
    charttime time
)

CREATE TABLE labevents (
    row_id number,
    subject_id number,
    hadm_id number,
    itemid number,
    charttime time,
    valuenum number,
    valueuom text
)

CREATE TABLE microbiologyevents (
    row_id number,
    subject_id number,
    hadm_id number,
    charttime time,
    spec_type_desc text,
    org_name text
)

CREATE TABLE transfers (
    row_id number,
    subject_id number,
    hadm_id number,
    icustay_id number,
    eventtype text,
    careunit text,
    wardid number,
    intime time,
    outtime time
)

CREATE TABLE d_items (
    row_id number,
    itemid number,
    label text,
    linksto text
)

CREATE TABLE inputevents_cv (
    row_id number,
    subject_id number,
    hadm_id number,
    icustay_id number,
    charttime time,
    itemid number,
    amount number
)

CREATE TABLE d_icd_diagnoses (
    row_id number,
    icd9_code text,
    short_title text,
    long_title text
)

CREATE TABLE patients (
    row_id number,
    subject_id number,
    gender text,
    dob time,
    dod time
)

CREATE TABLE d_icd_procedures (
    row_id number,
    icd9_code text,
    short_title text,
    long_title text
)

CREATE TABLE admissions (
    row_id number,
    subject_id number,
    hadm_id number,
    admittime time,
    dischtime time,
    admission_type text,
    admission_location text,
    discharge_location text,
    insurance text,
    language text,
    marital_status text,
    ethnicity text,
    age number
)

CREATE TABLE icustays (
    row_id number,
    subject_id number,
    hadm_id number,
    icustay_id number,
    first_careunit text,
    last_careunit text,
    first_wardid number,
    last_wardid number,
    intime time,
    outtime time
)

CREATE TABLE cost (
    row_id number,
    subject_id number,
    hadm_id number,
    event_type text,
    event_id number,
    chargetime time,
    cost number
)

Question: since 3 years ago, count the number of drugs that patient 19428 had been prescribed.

SQL:
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19428) AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-3 year')
Schema:
CREATE TABLE table_57614 (
    "Serial Title" text,
    "Year" text,
    "Chapters" text,
    "Director" text,
    "Cast" text
)

Question: Tell me the cast for b. reeves eason and joseph kane

SQL:
SELECT "Cast" FROM table_57614 WHERE "Director" = 'b. reeves eason and joseph kane'
Schema:
CREATE TABLE table_76555 (
    "Date" text,
    "Captain 1" text,
    "Team 2" text,
    "Captain 2" text,
    "Venue" text,
    "Result" text
)

Question: Which Captain 2 has a Result of final?

SQL:
SELECT "Captain 2" FROM table_76555 WHERE "Result" = 'final'
Schema:
CREATE TABLE table_33986 (
    "Date" text,
    "Visitor" text,
    "Score" text,
    "Home" text,
    "Record" text
)

Question: What was the record on April 1?

SQL:
SELECT "Record" FROM table_33986 WHERE "Date" = 'april 1'
Schema:
CREATE TABLE table_name_29 (
    entered_service VARCHAR,
    serial_no VARCHAR
)

Question: What is the entered service date for serial number 85-1222?

SQL:
SELECT entered_service FROM table_name_29 WHERE serial_no = "85-1222"
Schema:
CREATE TABLE table_21515673_2 (
    rr1_pts VARCHAR,
    team_name VARCHAR
)

Question: How many points does Swedish America's Cup Challenge have for rr1?

SQL:
SELECT COUNT(rr1_pts) FROM table_21515673_2 WHERE team_name = "Swedish America's Cup Challenge"
Schema:
CREATE TABLE table_name_24 (
    lowest INTEGER,
    average INTEGER
)

Question: What is the lowest attendance for a stadium that has an average smaller than 307?

SQL:
SELECT AVG(lowest) FROM table_name_24 WHERE average < 307
Schema:
CREATE TABLE table_22883210_11 (
    high_assists VARCHAR,
    series VARCHAR
)

Question: When 0-1 is the series who has the highest amount of assists?

SQL:
SELECT high_assists FROM table_22883210_11 WHERE series = "0-1"
Schema:
CREATE TABLE enroll (
    class_code text,
    stu_num number,
    enroll_grade text
)

CREATE TABLE employee (
    emp_num number,
    emp_lname text,
    emp_fname text,
    emp_initial text,
    emp_jobcode text,
    emp_hiredate time,
    emp_dob time
)

CREATE TABLE professor (
    emp_num number,
    dept_code text,
    prof_office text,
    prof_extension text,
    prof_high_degree text
)

CREATE TABLE class (
    class_code text,
    crs_code text,
    class_section text,
    class_time text,
    class_room text,
    prof_num number
)

CREATE TABLE course (
    crs_code text,
    dept_code text,
    crs_description text,
    crs_credit number
)

CREATE TABLE department (
    dept_code text,
    dept_name text,
    school_code text,
    emp_num number,
    dept_address text,
    dept_extension text
)

CREATE TABLE student (
    stu_num number,
    stu_lname text,
    stu_fname text,
    stu_init text,
    stu_dob time,
    stu_hrs number,
    stu_class text,
    stu_gpa number,
    stu_transfer number,
    dept_code text,
    stu_phone text,
    prof_num number
)

Question: What are the first names of all students taking accoutning and Computer Information Systems classes?

SQL:
SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN class AS T3 ON T2.class_code = T3.class_code JOIN course AS T4 ON T3.crs_code = T4.crs_code JOIN department AS T5 ON T5.dept_code = T4.dept_code WHERE T5.dept_name = 'Accounting' INTERSECT SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN class AS T3 ON T2.class_code = T3.class_code JOIN course AS T4 ON T3.crs_code = T4.crs_code JOIN department AS T5 ON T5.dept_code = T4.dept_code WHERE T5.dept_name = 'Computer Info. Systems'
Schema:
CREATE TABLE table_203_43 (
    id number,
    "polling firm" text,
    "month" text,
    "link" text,
    "favor" number,
    "oppose" number
)

Question: how many months had more than 55 favor votes ?

SQL:
SELECT COUNT("month") FROM table_203_43 WHERE "favor" > 55
Schema:
CREATE TABLE table_78401 (
    "Home team" text,
    "Home team score" text,
    "Away team" text,
    "Away team score" text,
    "Venue" text,
    "Crowd" real,
    "Date" text
)

Question: What was the score for south melbourne at home?

SQL:
SELECT "Home team score" FROM table_78401 WHERE "Home team" = 'south melbourne'
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 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
)

Question: what is the number of patients whose discharge location is long term care hospital and procedure long title is incision of vessel, lower limb arteries?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "LONG TERM CARE HOSPITAL" AND procedures.long_title = "Incision of vessel, lower limb arteries"

Question: count the number of patients whose marital status is widowed and procedure long title is laryngoscopy and other tracheoscopy.

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.marital_status = "WIDOWED" AND procedures.long_title = "Laryngoscopy and other tracheoscopy"

Question: Tell me the time of admission and primary disease for the patient with patient id 53707.

SQL:
SELECT demographic.diagnosis, demographic.admittime FROM demographic WHERE demographic.subject_id = "53707"
Schema:
CREATE TABLE table_test_24 (
    "id" int,
    "history_of_bleeding_diathesis" bool,
    "bleeding" int,
    "systolic_blood_pressure_sbp" int,
    "hemoglobin_a1c_hba1c" float,
    "blood_draw" bool,
    "renal_disease" bool,
    "allergy_to_aspirin" bool,
    "allergy_to_clopidogrel" bool,
    "cardiogenic_shock" bool,
    "allergy_to_prasugrel" bool,
    "platelet_count" float,
    "diastolic_blood_pressure_dbp" int,
    "symptomatic_hypotension" bool,
    "serum_total_cholesterol" int,
    "gastrointestinal_disease" bool,
    "serum_creatinine" float,
    "hypertension" bool,
    "age" float,
    "NOUSE" float
)

Question: previous gastrointestinal bleeding within 6 months, bleeding diathesis, platelet count < 100000 / mm3 or hemoglobin < 10 g / dl

SQL:
SELECT * FROM table_test_24 WHERE gastrointestinal_disease = 1 OR bleeding = 1 OR platelet_count < 100000 OR hemoglobin_a1c_hba1c < 10
Schema:
CREATE TABLE table_204_971 (
    id number,
    "m" number,
    "date" text,
    "tournament" text,
    "round" text,
    "ground" text,
    "opponent" text,
    "score" text,
    "attendance" number,
    "dinamo scorers" text,
    "report" text
)

Question: how many games were attended by at least 8,000 people ?

SQL:
SELECT COUNT(*) FROM table_204_971 WHERE "attendance" >= 8000
Schema:
CREATE TABLE region (
    Region_id int,
    Region_code text,
    Region_name text
)

CREATE TABLE storm (
    Storm_ID int,
    Name text,
    Dates_active text,
    Max_speed int,
    Damage_millions_USD real,
    Number_Deaths int
)

CREATE TABLE affected_region (
    Region_id int,
    Storm_ID int,
    Number_city_affected real
)

Question: For all storms with at least 1 death, compare the total number of deaths by dates_active attribute, sort by the names from low to high.

SQL:
SELECT Dates_active, Number_Deaths FROM storm WHERE Number_Deaths >= 1 ORDER BY Dates_active
Schema:
CREATE TABLE table_68512 (
    "Rank" real,
    "Lane" real,
    "Name" text,
    "Nationality" text,
    "Time" real
)

Question: Name the most time for katrin mei ner and rank less than 5

SQL:
SELECT MAX("Time") FROM table_68512 WHERE "Name" = 'katrin meißner' AND "Rank" < '5'
Schema:
CREATE TABLE table_26368963_1 (
    under_13 VARCHAR,
    year VARCHAR
)

Question: In the year 2009 who was the under-13?

SQL:
SELECT under_13 FROM table_26368963_1 WHERE year = 2009
Schema:
CREATE TABLE table_name_4 (
    horizontal_bar INTEGER,
    country VARCHAR,
    rings VARCHAR
)

Question: Name the highest Horizontal Bar which is in france and Rings smaller than 58.975?

SQL:
SELECT MAX(horizontal_bar) FROM table_name_4 WHERE country = "france" AND rings < 58.975
Schema:
CREATE TABLE table_name_74 (
    county VARCHAR,
    geo_id VARCHAR,
    latitude VARCHAR,
    ansi_code VARCHAR
)

Question: what is the county when the latitude is more than 48.581299, ansi code is more than 1037103 and the geo id is 3801985060?

SQL:
SELECT county FROM table_name_74 WHERE latitude > 48.581299 AND ansi_code > 1037103 AND geo_id = 3801985060
Schema:
CREATE TABLE climber (
    Climber_ID int,
    Name text,
    Country text,
    Time text,
    Points real,
    Mountain_ID int
)

CREATE TABLE mountain (
    Mountain_ID int,
    Name text,
    Height real,
    Prominence real,
    Range text,
    Country text
)

Question: Show the names of climbers and the heights of mountains they climb Show bar chart, and display in desc by the bars please.

SQL:
SELECT T1.Name, T2.Height FROM climber AS T1 JOIN mountain AS T2 ON T1.Mountain_ID = T2.Mountain_ID ORDER BY T1.Name DESC
Schema:
CREATE TABLE table_name_69 (
    total INTEGER,
    to_par VARCHAR,
    player VARCHAR
)

Question: How many strokes for arnold palmer with a to par of greater than 9?

SQL:
SELECT AVG(total) FROM table_name_69 WHERE to_par > 9 AND player = "arnold palmer"
Schema:
CREATE TABLE table_73703 (
    "Name" text,
    "Nation" text,
    "Seasons" text,
    "Championship titles" text,
    "Races (Starts)" text,
    "Poles" real,
    "Wins" real,
    "Podiums" real,
    "Fastest Laps" real,
    "Points (Dropped points)" text
)

Question: What were the starts when the points dropped 18?

SQL:
SELECT "Races (Starts)" FROM table_73703 WHERE "Points (Dropped points)" = '18'
Schema:
CREATE TABLE table_1341568_14 (
    opponent VARCHAR,
    incumbent VARCHAR
)

Question: Who was Henry Hyde's opponent in the race?

SQL:
SELECT opponent FROM table_1341568_14 WHERE incumbent = "Henry Hyde"
Schema:
CREATE TABLE field (
    fieldid int
)

CREATE TABLE dataset (
    datasetid int,
    datasetname varchar
)

CREATE TABLE author (
    authorid int,
    authorname varchar
)

CREATE TABLE venue (
    venueid int,
    venuename varchar
)

CREATE TABLE paperfield (
    fieldid int,
    paperid int
)

CREATE TABLE paperdataset (
    paperid int,
    datasetid int
)

CREATE TABLE keyphrase (
    keyphraseid int,
    keyphrasename varchar
)

CREATE TABLE cite (
    citingpaperid int,
    citedpaperid int
)

CREATE TABLE paper (
    paperid int,
    title varchar,
    venueid int,
    year int,
    numciting int,
    numcitedby int,
    journalid int
)

CREATE TABLE journal (
    journalid int,
    journalname varchar
)

CREATE TABLE paperkeyphrase (
    paperid int,
    keyphraseid int
)

CREATE TABLE writes (
    paperid int,
    authorid int
)

Question: which papers used NELL ?

SQL:
SELECT DISTINCT paper.paperid FROM dataset, paper, paperdataset WHERE dataset.datasetname = 'NELL' AND paperdataset.datasetid = dataset.datasetid AND paper.paperid = paperdataset.paperid
Schema:
CREATE TABLE table_name_47 (
    tournament VARCHAR,
    runner_s__up VARCHAR
)

Question: Which tournament has a Runner(s)-up of Gary McCord?

SQL:
SELECT tournament FROM table_name_47 WHERE runner_s__up = "gary mccord"