VishalCh/book-train huggingface dataset:
Schema:
CREATE TABLE countries (
    COUNTRY_ID varchar(2),
    COUNTRY_NAME varchar(40),
    REGION_ID decimal(10,0)
)

CREATE TABLE jobs (
    JOB_ID varchar(10),
    JOB_TITLE varchar(35),
    MIN_SALARY decimal(6,0),
    MAX_SALARY decimal(6,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 regions (
    REGION_ID decimal(5,0),
    REGION_NAME varchar(25)
)

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

CREATE TABLE employees (
    EMPLOYEE_ID decimal(6,0),
    FIRST_NAME varchar(20),
    LAST_NAME varchar(25),
    EMAIL varchar(25),
    PHONE_NUMBER varchar(20),
    HIRE_DATE date,
    JOB_ID varchar(10),
    SALARY decimal(8,2),
    COMMISSION_PCT decimal(2,2),
    MANAGER_ID decimal(6,0),
    DEPARTMENT_ID decimal(4,0)
)

CREATE TABLE locations (
    LOCATION_ID decimal(4,0),
    STREET_ADDRESS varchar(40),
    POSTAL_CODE varchar(12),
    CITY varchar(30),
    STATE_PROVINCE varchar(25),
    COUNTRY_ID varchar(2)
)

Question: For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of hire_date and the sum of salary bin hire_date by time, order total number in asc order.

SQL:
SELECT HIRE_DATE, SUM(SALARY) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SUM(SALARY)
Schema:
CREATE TABLE table_1914090_2 (
    europe VARCHAR,
    america VARCHAR
)

Question: How many members did Europe have the year that America had 403892?

SQL:
SELECT europe FROM table_1914090_2 WHERE america = 403892
Schema:
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 countries (
    COUNTRY_ID varchar(2),
    COUNTRY_NAME varchar(40),
    REGION_ID decimal(10,0)
)

CREATE TABLE jobs (
    JOB_ID varchar(10),
    JOB_TITLE varchar(35),
    MIN_SALARY decimal(6,0),
    MAX_SALARY decimal(6,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 employees (
    EMPLOYEE_ID decimal(6,0),
    FIRST_NAME varchar(20),
    LAST_NAME varchar(25),
    EMAIL varchar(25),
    PHONE_NUMBER varchar(20),
    HIRE_DATE date,
    JOB_ID varchar(10),
    SALARY decimal(8,2),
    COMMISSION_PCT decimal(2,2),
    MANAGER_ID decimal(6,0),
    DEPARTMENT_ID decimal(4,0)
)

CREATE TABLE locations (
    LOCATION_ID decimal(4,0),
    STREET_ADDRESS varchar(40),
    POSTAL_CODE varchar(12),
    CITY varchar(30),
    STATE_PROVINCE varchar(25),
    COUNTRY_ID varchar(2)
)

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

Question: For those employees who did not have any job in the past, find hire_date and the sum of manager_id bin hire_date by weekday, and visualize them by a bar chart, and rank by the total number of manager id in asc please.

SQL:
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY SUM(MANAGER_ID)
Schema:
CREATE TABLE table_11847 (
    "Driver" text,
    "Constructor" text,
    "Laps" real,
    "Time/Retired" text,
    "Grid" real
)

Question: What is the time/retired of Driver Masten Gregory Carroll Shelby when the constructor was Maserati, the Grid was larger than 10 and there were more than 2 laps?

SQL:
SELECT "Time/Retired" FROM table_11847 WHERE "Grid" > '10' AND "Laps" > '2' AND "Constructor" = 'maserati' AND "Driver" = 'masten gregory carroll shelby'
Schema:
CREATE TABLE table_30036 (
    "Semitological abbreviation" text,
    "Hebrew name" text,
    "Arabic name" text,
    "Morphological category" text,
    "Hebrew Form" text,
    "Arabic form" text,
    "Approximate translation" text
)

Question: How many hebrew forms are there for the arabic form yuktibu ?

SQL:
SELECT COUNT("Hebrew Form") FROM table_30036 WHERE "Arabic form" = 'yuktibu يكتب'
Schema:
CREATE TABLE table_name_40 (
    round INTEGER,
    player VARCHAR
)

Question: Which round was Joe Taylor selected in?

SQL:
SELECT SUM(round) FROM table_name_40 WHERE player = "joe taylor"
Schema:
CREATE TABLE table_2908 (
    "Episode" text,
    "First broadcast" text,
    "Davids team" text,
    "Lees team" text,
    "Scores" text
)

Question: Who is on the David's Team for the episode with the Lees Team of Jack Dee and Peter Serafinowicz

SQL:
SELECT "Davids team" FROM table_2908 WHERE "Lees team" = 'Jack Dee and Peter Serafinowicz'
Schema:
CREATE TABLE table_56984 (
    "Variant (with Niqqud )" text,
    "without Niqqud" text,
    "Phonemic Value" text,
    "Phonetic Realisation" text,
    "English example" text
)

Question: If a variant without niqqud is as final letter: or , what is the phonetic realisation?

SQL:
SELECT "Phonetic Realisation" FROM table_56984 WHERE "without Niqqud" = 'as final letter: ו or יו'
Schema:
CREATE TABLE table_name_67 (
    year INTEGER,
    award VARCHAR,
    nominee VARCHAR
)

Question: What was the year Bernadette Peters was a nominee for the Tony award?

SQL:
SELECT SUM(year) FROM table_name_67 WHERE award = "tony award" AND nominee = "bernadette peters"
Schema:
CREATE TABLE table_name_76 (
    field_goals INTEGER,
    touchdowns VARCHAR,
    points VARCHAR
)

Question: Which Field goals is the highest one that has Touchdowns of 0, and Points larger than 4?

SQL:
SELECT MAX(field_goals) FROM table_name_76 WHERE touchdowns = 0 AND points > 4
Schema:
CREATE TABLE Transactions_Lots (
    transaction_id INTEGER,
    lot_id INTEGER
)

CREATE TABLE Transactions (
    transaction_id INTEGER,
    investor_id INTEGER,
    transaction_type_code VARCHAR(10),
    date_of_transaction DATETIME,
    amount_of_transaction DECIMAL(19,4),
    share_count VARCHAR(40),
    other_details VARCHAR(255)
)

CREATE TABLE Lots (
    lot_id INTEGER,
    investor_id INTEGER,
    lot_details VARCHAR(255)
)

CREATE TABLE Sales (
    sales_transaction_id INTEGER,
    sales_details VARCHAR(255)
)

CREATE TABLE Investors (
    investor_id INTEGER,
    Investor_details VARCHAR(255)
)

CREATE TABLE Ref_Transaction_Types (
    transaction_type_code VARCHAR(10),
    transaction_type_description VARCHAR(80)
)

CREATE TABLE Purchases (
    purchase_transaction_id INTEGER,
    purchase_details VARCHAR(255)
)

Question: What are the purchase details of transactions with amount bigger than 10000, and count them by a bar chart, list by the the number of purchase details from low to high.

SQL:
SELECT purchase_details, COUNT(purchase_details) FROM Purchases AS T1 JOIN Transactions AS T2 ON T1.purchase_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction > 10000 GROUP BY purchase_details ORDER BY COUNT(purchase_details)
Schema:
CREATE TABLE table_name_83 (
    part_1 VARCHAR,
    part_3 VARCHAR
)

Question: What is Part 1, when Part 3 is 'heldu'?

SQL:
SELECT part_1 FROM table_name_83 WHERE part_3 = "heldu"
Schema:
CREATE TABLE table_name_31 (
    school_club_team VARCHAR,
    pick VARCHAR
)

Question: What school/club had pick 33?

SQL:
SELECT school_club_team FROM table_name_31 WHERE pick = 33
Schema:
CREATE TABLE table_name_81 (
    hs_principal VARCHAR,
    year VARCHAR
)

Question: Who is the h.s. principal during 1973-1974?

SQL:
SELECT hs_principal FROM table_name_81 WHERE year = "1973-1974"
Schema:
CREATE TABLE table_75348 (
    "Player" text,
    "Position" text,
    "Starter" text,
    "Touchdowns" real,
    "Extra points" real,
    "Field goals" real,
    "Points" real
)

Question: What is the highest field goals when there were more than 1 touchdown and 0 extra points?

SQL:
SELECT MAX("Field goals") FROM table_75348 WHERE "Touchdowns" > '1' AND "Extra points" > '0'
Schema:
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 diagnoses_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 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 d_items (
    row_id number,
    itemid number,
    label text,
    linksto 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 outputevents (
    row_id number,
    subject_id number,
    hadm_id number,
    icustay_id number,
    charttime time,
    itemid number,
    value number
)

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

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

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

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

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

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 d_icd_procedures (
    row_id number,
    icd9_code text,
    short_title text,
    long_title text
)

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

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

Question: when did patient 14054 get discharged from hospital for the first time since 2105?

SQL:
SELECT admissions.dischtime FROM admissions WHERE admissions.subject_id = 14054 AND STRFTIME('%y', admissions.dischtime) >= '2105' ORDER BY admissions.dischtime LIMIT 1
Schema:
CREATE TABLE table_name_4 (
    role VARCHAR,
    year VARCHAR,
    festival_organization VARCHAR
)

Question: What role was at the Sydney Film Festival in 2008?

SQL:
SELECT role FROM table_name_4 WHERE year = 2008 AND festival_organization = "sydney film festival"
Schema:
CREATE TABLE table_63515 (
    "Tournament" text,
    "2003" text,
    "2004" text,
    "2005" text,
    "2006" text,
    "2007" text,
    "2008" text,
    "2009" text,
    "2010" text,
    "2011" text,
    "2012" text,
    "Win %" text
)

Question: What is the 2007 value with a 1r in 2009?

SQL:
SELECT "2007" FROM table_63515 WHERE "2009" = '1r'
Schema:
CREATE TABLE table_name_71 (
    fatalities VARCHAR,
    aircraft VARCHAR
)

Question: What was the number of fatalities for the Viscount 700?

SQL:
SELECT fatalities FROM table_name_71 WHERE aircraft = "viscount 700"
Schema:
CREATE TABLE ref_document_types (
    document_type_code text,
    document_type_name text,
    document_type_description text
)

CREATE TABLE accounts (
    account_id number,
    statement_id number,
    account_details text
)

CREATE TABLE projects (
    project_id number,
    project_details text
)

CREATE TABLE documents (
    document_id number,
    document_type_code text,
    project_id number,
    document_date time,
    document_name text,
    document_description text,
    other_details text
)

CREATE TABLE documents_with_expenses (
    document_id number,
    budget_type_code text,
    document_details text
)

CREATE TABLE ref_budget_codes (
    budget_type_code text,
    budget_type_description text
)

CREATE TABLE statements (
    statement_id number,
    statement_details text
)

Question: What are the different statement ids on accounts, and the number of accounts for each?

SQL:
SELECT statement_id, COUNT(*) FROM accounts GROUP BY statement_id
Schema:
CREATE TABLE table_17130 (
    "Calculator" text,
    "CPU" text,
    "RAM" text,
    "Display Size" text,
    "Programming Languages" text,
    "Link Abilities" text,
    "Year Released" text,
    "Predecessors" text,
    "Successors" text
)

Question: what is the cpu for the calculator with 28 kb of ram and display size 128 64 pixels 21 8 characters?

SQL:
SELECT "CPU" FROM table_17130 WHERE "RAM" = '28 KB of RAM' AND "Display Size" = '128×64 pixels 21×8 characters'
Schema:
CREATE TABLE table_25355392_2 (
    june_10_11 VARCHAR,
    march_27_29 VARCHAR
)

Question: what is june 10-11 when march 27-29 is 149?

SQL:
SELECT june_10_11 FROM table_25355392_2 WHERE march_27_29 = "149"
Schema:
CREATE TABLE table_64515 (
    "Shirt No" real,
    "Nationality" text,
    "Player" text,
    "Birth Date" text,
    "Height" real,
    "Position" text
)

Question: What is the Shirt No for Henry Bell Cisnero whose height is less than 190?

SQL:
SELECT MAX("Shirt No") FROM table_64515 WHERE "Height" < '190' AND "Player" = 'henry bell cisnero'
Schema:
CREATE TABLE table_68293 (
    "Tournament" text,
    "2007" text,
    "2008" text,
    "2009" text,
    "2010" text,
    "2011" text,
    "2012" text,
    "2013" text
)

Question: Which tournament had a 2010 finish of 4R?

SQL:
SELECT "Tournament" FROM table_68293 WHERE "2010" = '4r'
Schema:
CREATE TABLE regions (
    REGION_ID decimal(5,0),
    REGION_NAME varchar(25)
)

CREATE TABLE locations (
    LOCATION_ID decimal(4,0),
    STREET_ADDRESS varchar(40),
    POSTAL_CODE varchar(12),
    CITY varchar(30),
    STATE_PROVINCE varchar(25),
    COUNTRY_ID varchar(2)
)

CREATE TABLE job_history (
    EMPLOYEE_ID decimal(6,0),
    START_DATE date,
    END_DATE date,
    JOB_ID varchar(10),
    DEPARTMENT_ID decimal(4,0)
)

CREATE TABLE countries (
    COUNTRY_ID varchar(2),
    COUNTRY_NAME varchar(40),
    REGION_ID decimal(10,0)
)

CREATE TABLE jobs (
    JOB_ID varchar(10),
    JOB_TITLE varchar(35),
    MIN_SALARY decimal(6,0),
    MAX_SALARY decimal(6,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)
)

Question: Just list the first name of the employee and show the location id of the corresponding department using a bar chart.

SQL:
SELECT FIRST_NAME, LOCATION_ID FROM employees AS T1 JOIN departments AS T2 ON T1.DEPARTMENT_ID = T2.DEPARTMENT_ID WHERE T1.EMPLOYEE_ID = T2.MANAGER_ID
Schema:
CREATE TABLE table_8627 (
    "Discipline" text,
    "Championship" text,
    "Circuit" text,
    "Session" text,
    "Cause" text
)

Question: What was the discipline for the euroboss championship?

SQL:
SELECT "Discipline" FROM table_8627 WHERE "Championship" = 'euroboss'
Schema:
CREATE TABLE microbiologyevents (
    row_id number,
    subject_id number,
    hadm_id number,
    charttime time,
    spec_type_desc text,
    org_name text
)

CREATE TABLE outputevents (
    row_id number,
    subject_id number,
    hadm_id number,
    icustay_id number,
    charttime time,
    itemid number,
    value number
)

CREATE TABLE cost (
    row_id number,
    subject_id number,
    hadm_id number,
    event_type text,
    event_id number,
    chargetime time,
    cost 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 labevents (
    row_id number,
    subject_id number,
    hadm_id number,
    itemid number,
    charttime time,
    valuenum number,
    valueuom 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 patients (
    row_id number,
    subject_id number,
    gender text,
    dob time,
    dod time
)

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

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_icd_diagnoses (
    row_id number,
    icd9_code text,
    short_title text,
    long_title text
)

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

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

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 d_icd_procedures (
    row_id number,
    icd9_code text,
    short_title text,
    long_title text
)

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 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_labitems (
    row_id number,
    itemid number,
    label text
)

Question: what is the cost of a drug, permethrin?

SQL:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'prescriptions' AND cost.event_id IN (SELECT prescriptions.row_id FROM prescriptions WHERE prescriptions.drug = 'permethrin')
Schema:
CREATE TABLE table_68420 (
    "Date" text,
    "Opponent" text,
    "Score" text,
    "Loss" text,
    "Attendance" text
)

Question: What was the score for the game that had an attendance of 41,087?

SQL:
SELECT "Score" FROM table_68420 WHERE "Attendance" = '41,087'
Schema:
CREATE TABLE table_2013618_1 (
    density VARCHAR,
    traditional VARCHAR
)

Question: Name the density for

SQL:
SELECT density FROM table_2013618_1 WHERE traditional = "古田縣"
Schema:
CREATE TABLE Parties_in_Events (
    Party_ID INTEGER,
    Event_ID INTEGER,
    Role_Code CHAR(15)
)

CREATE TABLE Agreements (
    Document_ID INTEGER,
    Event_ID INTEGER
)

CREATE TABLE Parties (
    Party_ID INTEGER,
    Party_Details VARCHAR(255)
)

CREATE TABLE Events (
    Event_ID INTEGER,
    Address_ID INTEGER,
    Channel_ID INTEGER,
    Event_Type_Code CHAR(15),
    Finance_ID INTEGER,
    Location_ID INTEGER
)

CREATE TABLE Channels (
    Channel_ID INTEGER,
    Other_Details VARCHAR(255)
)

CREATE TABLE Finances (
    Finance_ID INTEGER,
    Other_Details VARCHAR(255)
)

CREATE TABLE Products (
    Product_ID INTEGER,
    Product_Type_Code CHAR(15),
    Product_Name VARCHAR(255),
    Product_Price DECIMAL(20,4)
)

CREATE TABLE Addresses (
    Address_ID INTEGER,
    address_details VARCHAR(255)
)

CREATE TABLE Locations (
    Location_ID INTEGER,
    Other_Details VARCHAR(255)
)

CREATE TABLE Products_in_Events (
    Product_in_Event_ID INTEGER,
    Event_ID INTEGER,
    Product_ID INTEGER
)

CREATE TABLE Assets (
    Asset_ID INTEGER,
    Other_Details VARCHAR(255)
)

CREATE TABLE Assets_in_Events (
    Asset_ID INTEGER,
    Event_ID INTEGER
)

Question: List the number of the names of products that are not in any event, and rank x axis from high to low order please.

SQL:
SELECT Product_Name, COUNT(Product_Name) FROM Products WHERE NOT Product_ID IN (SELECT Product_ID FROM Products_in_Events) GROUP BY Product_Name ORDER BY Product_Name 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 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
)

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
)

Question: give me the number of patients whose diagnoses short title is enterococcus group d?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE diagnoses.short_title = "Enterococcus group d"

Question: Count the number of patients on a main drug type prescription with diagnoses icd9 code 41512.

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.icd9_code = "41512" AND prescriptions.drug_type = "MAIN"

Question: provide the time of admission and prescribed drug for the patient with patient id 18480.

SQL:
SELECT demographic.admittime, prescriptions.drug FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.subject_id = "18480"
Schema:
CREATE TABLE customers (
    customer_id number,
    customer_address_id number,
    customer_status_code text,
    date_became_customer time,
    date_of_birth time,
    first_name text,
    last_name text,
    amount_outstanding number,
    email_address text,
    phone_number text,
    cell_mobile_phone_number text
)

CREATE TABLE addresses (
    address_id number,
    line_1_number_building text,
    city text,
    zip_postcode text,
    state_province_county text,
    country text
)

CREATE TABLE vehicles (
    vehicle_id number,
    vehicle_details text
)

CREATE TABLE lessons (
    lesson_id number,
    customer_id number,
    lesson_status_code text,
    staff_id number,
    vehicle_id number,
    lesson_date time,
    lesson_time text,
    price number
)

CREATE TABLE staff (
    staff_id number,
    staff_address_id number,
    nickname text,
    first_name text,
    middle_name text,
    last_name text,
    date_of_birth time,
    date_joined_staff time,
    date_left_staff time
)

CREATE TABLE customer_payments (
    customer_id number,
    datetime_payment time,
    payment_method_code text,
    amount_payment number
)

Question: How many lessons did the customer with the first name Ray take?

SQL:
SELECT COUNT(*) FROM lessons AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = "Ray"