VishalCh/book-train huggingface dataset:
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 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 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 lab (
    subject_id text,
    hadm_id text,
    itemid text,
    charttime text,
    flag text,
    value_unit text,
    label text,
    fluid text
)

Question: what is maximum age of patients whose gender is m and discharge location is short term hospital?

SQL:
SELECT MAX(demographic.age) FROM demographic WHERE demographic.gender = "M" AND demographic.discharge_location = "SHORT TERM HOSPITAL"

Question: provide the number of patients whose marital status is married and admission year is less than 2108?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.marital_status = "MARRIED" AND demographic.admityear < "2108"
Schema:
CREATE TABLE table_54761 (
    "Draw" real,
    "Artist" text,
    "Song" text,
    "Points" real,
    "Place" text
)

Question: What is the draw number that has 59 points?

SQL:
SELECT AVG("Draw") FROM table_54761 WHERE "Points" = '59'
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 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 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: how many patients under the age of 80 years had their lab test fluid as joint fluid?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.age < "80" AND lab.fluid = "Joint Fluid"

Question: how many patients are admitted urgently and lab tested for bilirubin,direct?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admission_type = "URGENT" AND lab.label = "Bilirubin, Direct"

Question: what is maximum age of patients whose language is engl and primary disease is hypertension;rule out coronary artery disease\cardiac cath?

SQL:
SELECT MAX(demographic.age) FROM demographic WHERE demographic.language = "ENGL" AND demographic.diagnosis = "HYPERTENSION;RULE OUT CORONARY ARTERY DISEASE\CARDIAC CATH"
Schema:
CREATE TABLE lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime time
)

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

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

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 cost (
    costid number,
    uniquepid text,
    patienthealthsystemstayid number,
    eventtype text,
    eventid number,
    chargetime time,
    cost number
)

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

Question: what was patient 025-30850's weight the last time in 06/2105?

SQL:
SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-30850') AND NOT patient.admissionweight IS NULL AND STRFTIME('%y-%m', patient.unitadmittime) = '2105-06' ORDER BY patient.unitadmittime DESC LIMIT 1
Schema:
CREATE TABLE table_38483 (
    "Name" text,
    "Team" text,
    "Qual 1" text,
    "Qual 2" real,
    "Best" real
)

Question: Who had a Qualifying 2 time over 58.669 for Team Australia?

SQL:
SELECT "Name" FROM table_38483 WHERE "Qual 2" > '58.669' AND "Team" = 'team australia'
Schema:
CREATE TABLE vocals (
    songid VARCHAR
)

CREATE TABLE songs (
    songid VARCHAR
)

Question: How many songs have a shared vocal?

SQL:
SELECT COUNT(DISTINCT title) FROM vocals AS T1 JOIN songs AS T2 ON T1.songid = T2.songid WHERE TYPE = "shared"
Schema:
CREATE TABLE table_74485 (
    "Year" real,
    "Azerbaijan" real,
    "Armenia" real,
    "Belarus" real,
    "Georgia" real,
    "Kazakhstan" real,
    "Kyrghizstan" real,
    "Latvia" real,
    "Lithuania" real,
    "Moldova" real,
    "Russia" real,
    "Tajikistan" real,
    "Turkmenikstan" real,
    "Uzbekistan" real,
    "Ukraine" real,
    "Estonia" real
)

Question: Tell me the lowest kazakhstan for kyrghizstan of 4.62 and belarus less than 2.46

SQL:
SELECT MIN("Kazakhstan") FROM table_74485 WHERE "Kyrghizstan" = '4.62' AND "Belarus" < '2.46'
Schema:
CREATE TABLE table_204_418 (
    id number,
    "date" text,
    "opponent" text,
    "score" text,
    "overall record" text,
    "scba record" text
)

Question: how many games were played in total ?

SQL:
SELECT COUNT(*) FROM table_204_418
Schema:
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 regions (
    REGION_ID decimal(5,0),
    REGION_NAME varchar(25)
)

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 departments (
    DEPARTMENT_ID decimal(4,0),
    DEPARTMENT_NAME varchar(30),
    MANAGER_ID decimal(6,0),
    LOCATION_ID decimal(4,0)
)

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

Question: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of employee_id over the hire_date bin hire_date by weekday by a bar chart.

SQL:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
Schema:
CREATE TABLE table_204_442 (
    id number,
    "institution" text,
    "location" text,
    "enrollment" number,
    "nickname" text,
    "varsity\nsports" number,
    "rugby\nsince" text,
    "head coach" text
)

Question: which institution has the highest amount of enrollment ?

SQL:
SELECT "institution" FROM table_204_442 ORDER BY "enrollment" DESC LIMIT 1
Schema:
CREATE TABLE table_name_29 (
    league_division VARCHAR,
    location VARCHAR
)

Question: What League/Division has a Location of n/a?

SQL:
SELECT league_division FROM table_name_29 WHERE location = "n/a"
Schema:
CREATE TABLE table_75478 (
    "Year" text,
    "Overall Record" text,
    "Conference Record" text,
    "Coach" text,
    "Conference" text
)

Question: What is the conference record for the year of 1971?

SQL:
SELECT "Conference Record" FROM table_75478 WHERE "Year" = '1971'
Schema:
CREATE TABLE table_47224 (
    "Player" text,
    "Nationality" text,
    "Jersey Number(s)" text,
    "Position" text,
    "Years" text,
    "From" text
)

Question: What years were from Connecticut?

SQL:
SELECT "Years" FROM table_47224 WHERE "From" = 'connecticut'
Schema:
CREATE TABLE table_name_75 (
    message VARCHAR,
    designation_hd VARCHAR
)

Question: What message has hd 186408 as a designation HD?

SQL:
SELECT message FROM table_name_75 WHERE designation_hd = "hd 186408"
Schema:
CREATE TABLE Apartment_Buildings (
    building_id INTEGER,
    building_short_name CHAR(15),
    building_full_name VARCHAR(80),
    building_description VARCHAR(255),
    building_address VARCHAR(255),
    building_manager VARCHAR(50),
    building_phone VARCHAR(80)
)

CREATE TABLE Apartment_Bookings (
    apt_booking_id INTEGER,
    apt_id INTEGER,
    guest_id INTEGER,
    booking_status_code CHAR(15),
    booking_start_date DATETIME,
    booking_end_date DATETIME
)

CREATE TABLE Apartment_Facilities (
    apt_id INTEGER,
    facility_code CHAR(15)
)

CREATE TABLE View_Unit_Status (
    apt_id INTEGER,
    apt_booking_id INTEGER,
    status_date DATETIME,
    available_yn BIT
)

CREATE TABLE Guests (
    guest_id INTEGER,
    gender_code CHAR(1),
    guest_first_name VARCHAR(80),
    guest_last_name VARCHAR(80),
    date_of_birth DATETIME
)

CREATE TABLE Apartments (
    apt_id INTEGER,
    building_id INTEGER,
    apt_type_code CHAR(15),
    apt_number CHAR(10),
    bathroom_count INTEGER,
    bedroom_count INTEGER,
    room_count CHAR(5)
)

Question: What are the number of the facility codes of the apartments with more than four bedrooms?, and list by the y axis from high to low.

SQL:
SELECT facility_code, COUNT(facility_code) FROM Apartment_Facilities AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.bedroom_count > 4 GROUP BY facility_code ORDER BY COUNT(facility_code) DESC
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 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 diagnoses (
    subject_id text,
    hadm_id text,
    icd9_code text,
    short_title text,
    long_title text
)

Question: what is the diagnosis icd9 code for patient name kurt buczek?

SQL:
SELECT diagnoses.icd9_code FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.name = "Kurt Buczek"

Question: count the number of patients whose year of death is less than or equal to 2186 and diagnoses long title is hyperacusis?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dod_year <= "2186.0" AND diagnoses.long_title = "Hyperacusis"

Question: count the number of patients born before the year 2049.

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.dob_year < "2049"

Question: among patients diagnosed with hemochromatosis due to repeated red blood cell transfusions, how many of them were unmarried?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.marital_status = "SINGLE" AND diagnoses.long_title = "Hemochromatosis due to repeated red blood cell transfusions"
Schema:
CREATE TABLE table_name_21 (
    value__ VARCHAR,
    team VARCHAR,
    revenue__$m_ VARCHAR,
    rank VARCHAR
)

Question: Name the total number of value for revenue more than 193 and rank less than 12 for manchester united

SQL:
SELECT COUNT(value__) AS $m_ FROM table_name_21 WHERE revenue__$m_ > 193 AND rank < 12 AND team = "manchester united"
Schema:
CREATE TABLE table_49867 (
    "Date" text,
    "Home team" text,
    "Score" text,
    "Away team" text,
    "Venue" text,
    "Box Score" text,
    "Report" text
)

Question: Which home team had a score of 85-101?

SQL:
SELECT "Home team" FROM table_49867 WHERE "Score" = '85-101'
Schema:
CREATE TABLE Student (
    StuID INTEGER,
    LName VARCHAR(12),
    Fname VARCHAR(12),
    Age INTEGER,
    Sex VARCHAR(1),
    Major INTEGER,
    Advisor INTEGER,
    city_code VARCHAR(3)
)

CREATE TABLE Allergy_Type (
    Allergy VARCHAR(20),
    AllergyType VARCHAR(20)
)

CREATE TABLE Has_Allergy (
    StuID INTEGER,
    Allergy VARCHAR(20)
)

Question: What is the number of each allergie that the student with first name Lisa has? Draw a bar chart.

SQL:
SELECT T1.Allergy, COUNT(T1.Allergy) FROM Allergy_Type AS T1 JOIN Has_Allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T3.StuID = T2.StuID WHERE T3.Fname = "Lisa" GROUP BY T1.Allergy
Schema:
CREATE TABLE table_25437 (
    "Edition" text,
    "Round" text,
    "Date" text,
    "Against" text,
    "Surface" text,
    "Opponent" text,
    "W\u2013L" text,
    "Result" text
)

Question: Name the opponent for 3 6, 4 6, 6 1, 6 7 (7 9)

SQL:
SELECT "Opponent" FROM table_25437 WHERE "Result" = '3–6, 4–6, 6–1, 6–7 (7–9)'
Schema:
CREATE TABLE table_name_86 (
    high_rebounds VARCHAR,
    high_assists VARCHAR
)

Question: What is High Rebounds, when High Assists is 'Delonte West (10)'?

SQL:
SELECT high_rebounds FROM table_name_86 WHERE high_assists = "delonte west (10)"
Schema:
CREATE TABLE Movie (
    mID VARCHAR,
    year VARCHAR
)

CREATE TABLE Rating (
    mID VARCHAR,
    stars VARCHAR
)

Question: Find all years that have a movie that received a rating of 4 or 5, and sort them in increasing order of year.

SQL:
SELECT DISTINCT year FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID WHERE T2.stars >= 4 ORDER BY T1.year
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 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 diagnoses (
    subject_id text,
    hadm_id text,
    icd9_code text,
    short_title text,
    long_title 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 discharge location is home health care and admission year is less than 2158?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.discharge_location = "HOME HEALTH CARE" AND demographic.admityear < "2158"

Question: what is the number of patients whose ethnicity is hispanic/latino - puerto rican and drug name is influenza virus vaccine?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND prescriptions.drug = "Influenza Virus Vaccine"
Schema:
CREATE TABLE table_77939 (
    "Player" text,
    "Date of Birth" text,
    "Batting Style" text,
    "Bowling Style" text,
    "First Class Team" text
)

Question: What first class team does sanath jayasuriya play for?

SQL:
SELECT "First Class Team" FROM table_77939 WHERE "Player" = 'sanath jayasuriya'
Schema:
CREATE TABLE table_23315 (
    "Verbs" text,
    "Yo" text,
    "T\u00fa" text,
    "Vos (*)" text,
    "\u00c9l / Ella / Usted" text,
    "Nosotros / Nosotras" text,
    "Vosotros / Vosotras" text,
    "Ellos / Ellas / Ustedes" text
)

Question: how many verbs have the yo form as sienta?

SQL:
SELECT COUNT("Verbs") FROM table_23315 WHERE "Yo" = 'sienta'
Schema:
CREATE TABLE table_203_530 (
    id number,
    "country" text,
    "gdp (usd bln, 2012)" number,
    "gdp (usd bln, 2017)" number,
    "gdp (usd ppp bln, 2012)" number,
    "gdp (usd ppp bln, 2017)" number,
    "per capita (usd, 2012)" number,
    "per capita (usd, 2017)" number,
    "per capita (usd ppp, 2012)" number,
    "per capita (usd ppp, 2017)" number
)

Question: what is the difference in 2012 gdp between albania and algeria ?

SQL:
SELECT ABS((SELECT "gdp (usd bln, 2012)" FROM table_203_530 WHERE "country" = 'albania') - (SELECT "gdp (usd bln, 2012)" FROM table_203_530 WHERE "country" = 'algeria'))
Schema:
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 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 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 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 vitalperiodic (
    vitalperiodicid number,
    patientunitstayid number,
    temperature number,
    sao2 number,
    heartrate number,
    respiration number,
    systemicsystolic number,
    systemicdiastolic number,
    systemicmean number,
    observationtime time
)

Question: how much different is patient 016-8658's weight last measured on the first hospital visit compared to the value first measured on the first hospital visit?

SQL:
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-8658' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) - (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-8658' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
Schema:
CREATE TABLE ref_attraction_types (
    attraction_type_code text,
    attraction_type_description text
)

CREATE TABLE features (
    feature_id number,
    feature_details text
)

CREATE TABLE tourist_attraction_features (
    tourist_attraction_id number,
    feature_id number
)

CREATE TABLE staff (
    staff_id number,
    tourist_attraction_id number,
    name text,
    other_details text
)

CREATE TABLE ref_hotel_star_ratings (
    star_rating_code text,
    star_rating_description text
)

CREATE TABLE visits (
    visit_id number,
    tourist_attraction_id number,
    tourist_id number,
    visit_date time,
    visit_details text
)

CREATE TABLE museums (
    museum_id number,
    museum_details text
)

CREATE TABLE photos (
    photo_id number,
    tourist_attraction_id number,
    name text,
    description text,
    filename text,
    other_details text
)

CREATE TABLE shops (
    shop_id number,
    shop_details text
)

CREATE TABLE visitors (
    tourist_id number,
    tourist_details text
)

CREATE TABLE street_markets (
    market_id number,
    market_details text
)

CREATE TABLE hotels (
    hotel_id number,
    star_rating_code text,
    pets_allowed_yn text,
    price_range number,
    other_hotel_details text
)

CREATE TABLE theme_parks (
    theme_park_id number,
    theme_park_details text
)

CREATE TABLE royal_family (
    royal_family_id number,
    royal_family_details text
)

CREATE TABLE locations (
    location_id number,
    location_name text,
    address text,
    other_details text
)

CREATE TABLE tourist_attractions (
    tourist_attraction_id number,
    attraction_type_code text,
    location_id number,
    how_to_get_there text,
    name text,
    description text,
    opening_hours text,
    other_details text
)

Question: Show all distinct location names.

SQL:
SELECT DISTINCT location_name FROM locations