VishalCh/book-train huggingface dataset:
Schema:
CREATE TABLE table_204_795 (
    id number,
    "date" text,
    "opponent" text,
    "score" text,
    "result" text,
    "location" text,
    "attendance" number
)

Question: was the last game a win or a loss ?

SQL:
SELECT "result" FROM table_204_795 ORDER BY "date" DESC 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 lab (
    subject_id text,
    hadm_id text,
    itemid text,
    charttime text,
    flag text,
    value_unit text,
    label text,
    fluid 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: count the number of patients whose marital status is single and lab test name is hyaline casts?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.marital_status = "SINGLE" AND lab.label = "Hyaline Casts"

Question: count the number of patients whose insurance is private and admission location is clinic referral/premature.

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.insurance = "Private" AND demographic.admission_location = "CLINIC REFERRAL/PREMATURE"
Schema:
CREATE TABLE table_54160 (
    "Outcome" text,
    "Date" text,
    "Tournament" text,
    "Surface" text,
    "Opponent in the final" text,
    "Score in the final" text
)

Question: What was the surface where the outcome was winner on 12 march 1989?

SQL:
SELECT "Surface" FROM table_54160 WHERE "Outcome" = 'winner' AND "Date" = '12 march 1989'
Schema:
CREATE TABLE table_1570003_2 (
    open_cup VARCHAR,
    year VARCHAR
)

Question: During 2003 what was open cup qualifying status?

SQL:
SELECT open_cup FROM table_1570003_2 WHERE year = 2003
Schema:
CREATE TABLE table_17901155_4 (
    original_us_air_date VARCHAR,
    viewers__millions_ VARCHAR
)

Question: Which US air date had 4.4 million viewers?

SQL:
SELECT original_us_air_date FROM table_17901155_4 WHERE viewers__millions_ = "4.4"
Schema:
CREATE TABLE table_name_65 (
    score VARCHAR,
    date VARCHAR
)

Question: What was the score for the game on June 30?

SQL:
SELECT score FROM table_name_65 WHERE date = "june 30"
Schema:
CREATE TABLE table_15203 (
    "Year" real,
    "Entrant" text,
    "Chassis" text,
    "Engine" text,
    "Points" real
)

Question: What is the earliest year that has a Bristol engine?

SQL:
SELECT MIN("Year") FROM table_15203 WHERE "Engine" = 'bristol'
Schema:
CREATE TABLE table_41506 (
    "Number" real,
    "Name" text,
    "Builder" text,
    "Type" text,
    "Date" text,
    "Works number" text
)

Question: In early 1873, Owen sound had what works number?

SQL:
SELECT "Works number" FROM table_41506 WHERE "Date" = 'early 1873' AND "Name" = 'owen sound'
Schema:
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
)

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

Question: when was the first time that patient 009-5001 was prescribed medication on this hospital encounter via oral route?

SQL:
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-5001' AND patient.hospitaldischargetime IS NULL)) AND medication.routeadmin = 'oral' ORDER BY medication.drugstarttime LIMIT 1
Schema:
CREATE TABLE table_name_48 (
    team_2 VARCHAR
)

Question: What is the 1st leg of cs sfaxien?

SQL:
SELECT 1 AS st_leg FROM table_name_48 WHERE team_2 = "cs sfaxien"
Schema:
CREATE TABLE Ref_Product_Categories (
    product_category_code VARCHAR(15),
    product_category_description VARCHAR(80),
    unit_of_measure VARCHAR(20)
)

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 Ref_Characteristic_Types (
    characteristic_type_code VARCHAR(15),
    characteristic_type_description VARCHAR(80)
)

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

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

Question: Find the number of the category descriptions of the products whose descriptions include letter 't', list names 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 product_category_description
Schema:
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 stadium (
    ID int,
    name text,
    Capacity int,
    City text,
    Country text,
    Opening_year int
)

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

Question: Return a bar chart about the distribution of meter_600 and ID , list in asc by the names please.

SQL:
SELECT meter_600, ID FROM swimmer ORDER BY meter_600

Question: Bar graph to show meter_100 from different meter 400, and could you display by the y axis in asc?

SQL:
SELECT meter_400, meter_100 FROM swimmer ORDER BY meter_100
Schema:
CREATE TABLE table_name_90 (
    team_2 VARCHAR,
    team_1 VARCHAR,
    result VARCHAR
)

Question: What team is 2 when 1 is Taipower and the result is 0-1?

SQL:
SELECT team_2 FROM table_name_90 WHERE team_1 = "taipower" AND result = "0-1"
Schema:
CREATE TABLE table_name_45 (
    system VARCHAR,
    name VARCHAR
)

Question: Which System's Name is Gemulator?

SQL:
SELECT system FROM table_name_45 WHERE name = "gemulator"
Schema:
CREATE TABLE table_name_96 (
    name VARCHAR,
    years VARCHAR
)

Question: What is the name of the head coach of 1974?

SQL:
SELECT name FROM table_name_96 WHERE years = "1974"
Schema:
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
)

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: count the number of dead patients who were diagnosed with noninf gastroenterit nec.

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.expire_flag = "1" AND diagnoses.short_title = "Noninf gastroenterit NEC"

Question: provide the number of patients whose ethnicity is american indian/alaska native and drug code is benz1i?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND prescriptions.formulary_drug_cd = "BENZ1I"
Schema:
CREATE TABLE table_204_89 (
    id number,
    "team" text,
    "truck(s)" text,
    "#" number,
    "driver(s)" text,
    "primary sponsor(s)" text,
    "listed owner(s)" text,
    "crew chief" text
)

Question: according to the chart , which team is listed to have the first dodge ram ?

SQL:
SELECT "team" FROM table_204_89 WHERE "truck(s)" = 'dodge ram' ORDER BY id LIMIT 1
Schema:
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 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 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: give the number of patients whose admission type is elective and lab test category is blood gas.

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND lab."CATEGORY" = "Blood Gas"
Schema:
CREATE TABLE table_name_77 (
    plaid_cymru VARCHAR,
    polling_organisation_client VARCHAR,
    date_s__conducted VARCHAR
)

Question: I want the plaid cymru for Polling organisation/client of yougov/itv wales for 4 may 2011

SQL:
SELECT plaid_cymru FROM table_name_77 WHERE polling_organisation_client = "yougov/itv wales" AND date_s__conducted = "4 may 2011"
Schema:
CREATE TABLE county_public_safety (
    Name VARCHAR,
    Population VARCHAR
)

Question: List the name of the county with the largest population.

SQL:
SELECT Name FROM county_public_safety ORDER BY Population DESC LIMIT 1
Schema:
CREATE TABLE table_name_31 (
    team_1 VARCHAR
)

Question: What is the 2nd leg of team 1 Zamalek SC?

SQL:
SELECT 2 AS nd_leg FROM table_name_31 WHERE team_1 = "zamalek sc"
Schema:
CREATE TABLE table_name_26 (
    week_4 VARCHAR,
    week_3 VARCHAR
)

Question: What is the week 3, prior to the when the week 4 was Laura Nicole?

SQL:
SELECT week_4 FROM table_name_26 WHERE week_3 = "laura nicole"
Schema:
CREATE TABLE routes (
    dst_apid VARCHAR
)

CREATE TABLE airports (
    apid VARCHAR,
    country VARCHAR
)

Question: Find the number of routes with destination airports in Italy.

SQL:
SELECT COUNT(*) FROM routes AS T1 JOIN airports AS T2 ON T1.dst_apid = T2.apid WHERE T2.country = 'Italy'
Schema:
CREATE TABLE table_204_853 (
    id number,
    "pos" number,
    "grid" number,
    "no." number,
    "driver" text,
    "team" text,
    "manufacturer" text,
    "laps" number,
    "points" number
)

Question: who is the first driver listed ?

SQL:
SELECT "driver" FROM table_204_853 WHERE id = 1
Schema:
CREATE TABLE table_13514 (
    "Model number" text,
    "sSpec number" text,
    "Cores" text,
    "Frequency" text,
    "Turbo" text,
    "L2 cache" text,
    "L3 cache" text,
    "GPU model" text,
    "GPU frequency" text,
    "Socket" text,
    "I/O bus" text,
    "Release date" text,
    "Part number(s)" text,
    "Release price ( USD )" text
)

Question: What is the l3 cache when the sspec number is sr0r2(l1)sr0t6(l1)?

SQL:
SELECT "L3 cache" FROM table_13514 WHERE "sSpec number" = 'sr0r2(l1)sr0t6(l1)'
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 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 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
)

Question: what is age and religion of subject id 84129?

SQL:
SELECT demographic.age, demographic.religion FROM demographic WHERE demographic.subject_id = "84129"

Question: calculate the minimum age of home health care discharged patients who had overdose primary disease.

SQL:
SELECT MIN(demographic.age) FROM demographic WHERE demographic.discharge_location = "HOME HEALTH CARE" AND demographic.diagnosis = "OVERDOSE"
Schema:
CREATE TABLE paperfield (
    fieldid int,
    paperid int
)

CREATE TABLE field (
    fieldid int
)

CREATE TABLE venue (
    venueid int,
    venuename varchar
)

CREATE TABLE writes (
    paperid int,
    authorid int
)

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 keyphrase (
    keyphraseid int,
    keyphrasename varchar
)

CREATE TABLE paperkeyphrase (
    paperid int,
    keyphraseid int
)

CREATE TABLE author (
    authorid int,
    authorname varchar
)

CREATE TABLE paperdataset (
    paperid int,
    datasetid int
)

CREATE TABLE dataset (
    datasetid int,
    datasetname varchar
)

CREATE TABLE journal (
    journalid int,
    journalname varchar
)

Question: new semantic parsing papers

SQL:
SELECT DISTINCT paper.paperid, paper.year FROM keyphrase, paper, paperkeyphrase WHERE keyphrase.keyphrasename = 'semantic parsing' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid ORDER BY paper.year DESC
Schema:
CREATE TABLE table_name_76 (
    event VARCHAR,
    position VARCHAR,
    year VARCHAR
)

Question: Which event had 4th place and took place in the year 2007?

SQL:
SELECT event FROM table_name_76 WHERE position = "4th" AND year = 2007
Schema:
CREATE TABLE table_name_9 (
    tankers VARCHAR,
    staffing VARCHAR,
    hazmat VARCHAR,
    platforms VARCHAR
)

Question: Which Tankers have a Hazmat of , and Platforms of , and a Staffing of volunteer?

SQL:
SELECT tankers FROM table_name_9 WHERE hazmat = "–" AND platforms = "–" AND staffing = "volunteer"
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 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 diagnoses (
    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: How many patients are born before 2197 and with procedure icd9 code 309?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dob_year < "2197" AND procedures.icd9_code = "309"

Question: how many unmarried patients have dialys route of drug administration?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.marital_status = "SINGLE" AND prescriptions.route = "DIALYS"

Question: what is the drug type and route prescribed for the drug code posa200l?

SQL:
SELECT prescriptions.drug_type, prescriptions.route FROM prescriptions WHERE prescriptions.formulary_drug_cd = "POSA200L"

Question: let me know the number of patients taking drug via sl route suffering from pneumonia primary disease.

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "PNEUMONIA" AND prescriptions.route = "SL"
Schema:
CREATE TABLE table_70219 (
    "Date" text,
    "City" text,
    "Event" text,
    "Winner" text,
    "Prize" text
)

Question: The EPT German open was won by which listed winner?

SQL:
SELECT "Winner" FROM table_70219 WHERE "Event" = 'ept german open'
Schema:
CREATE TABLE table_203_392 (
    id number,
    "rank" text,
    "belt alternate 1" text,
    "belt alternate 2" text,
    "belt alternate 3" text,
    "belt alternate 4" text
)

Question: how many different ranks exist for karate belts ?

SQL:
SELECT COUNT(DISTINCT "rank") FROM table_203_392
Schema:
CREATE TABLE table_21310 (
    "Game" real,
    "Date" text,
    "Opponent" text,
    "Score" text,
    "High points" text,
    "High rebounds" text,
    "High assists" text,
    "Location/Attendance" text,
    "Record" text
)

Question: Name the record for attendance location of palace of auburn hills 15,210

SQL:
SELECT "Record" FROM table_21310 WHERE "Location/Attendance" = 'Palace of Auburn Hills 15,210'
Schema:
CREATE TABLE table_204_937 (
    id number,
    "rank" number,
    "lane" number,
    "athlete" text,
    "time" number
)

Question: how long did it take the fifth place finisher to run the race ?

SQL:
SELECT "time" FROM table_204_937 WHERE "rank" = 5
Schema:
CREATE TABLE table_32339 (
    "Home team" text,
    "Home team score" text,
    "Away team" text,
    "Away team score" text,
    "Venue" text,
    "Crowd" real,
    "Date" text
)

Question: What did the home team score when playing at Western Oval?

SQL:
SELECT "Home team score" FROM table_32339 WHERE "Venue" = 'western oval'
Schema:
CREATE TABLE table_36349 (
    "Outcome" text,
    "Date" text,
    "Surface" text,
    "Partner" text,
    "Opponents" text,
    "Score" text
)

Question: Which Opponents have a Partner of irina-camelia begu, and a Surface of hard?

SQL:
SELECT "Opponents" FROM table_36349 WHERE "Partner" = 'irina-camelia begu' AND "Surface" = 'hard'
Schema:
CREATE TABLE table_train_159 (
    "id" int,
    "hemoglobin_a1c_hba1c" float,
    "estimated_glomerular_filtration_rate_egfr" int,
    "kidney_disease" bool,
    "serum_triglyceride" int,
    "body_mass_index_bmi" float,
    "age" float,
    "NOUSE" float
)

Question: presence of chronic kidney disease ( gfr < 45 ml / min )

SQL:
SELECT * FROM table_train_159 WHERE kidney_disease = 1 OR estimated_glomerular_filtration_rate_egfr < 45