VishalCh/book-train huggingface dataset:
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 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
)

Question: count the number of patients whose ethnicity is black/african american and year of birth is less than 2076?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.ethnicity = "BLACK/AFRICAN AMERICAN" AND demographic.dob_year < "2076"
Schema:
CREATE TABLE table_23235767_1 (
    year VARCHAR,
    opponent_in_the_final VARCHAR,
    championship VARCHAR
)

Question: What is every year where opponent in the final is John Mcenroe at Wimbledon?

SQL:
SELECT year FROM table_23235767_1 WHERE opponent_in_the_final = "John McEnroe" AND championship = "Wimbledon"
Schema:
CREATE TABLE table_33727 (
    "Home team" text,
    "Home team score" text,
    "Away team" text,
    "Away team score" text,
    "Venue" text,
    "Crowd" real,
    "Date" text
)

Question: What was the home team for the game with more than 25,000 crowd?

SQL:
SELECT "Home team" FROM table_33727 WHERE "Crowd" > '25,000'
Schema:
CREATE TABLE table_name_89 (
    performance VARCHAR,
    athlete VARCHAR
)

Question: What's the performance of Dire Tune?

SQL:
SELECT performance FROM table_name_89 WHERE athlete = "dire tune"
Schema:
CREATE TABLE departments (
    DEPARTMENT_ID decimal(4,0),
    DEPARTMENT_NAME varchar(30),
    MANAGER_ID decimal(6,0),
    LOCATION_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)
)

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

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 last_name and salary , show in descending by the X.

SQL:
SELECT LAST_NAME, SALARY FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY LAST_NAME DESC
Schema:
CREATE TABLE table_26503 (
    "Rnd" real,
    "Circuit" text,
    "LMP Winning Team" text,
    "LMPC Winning Team" text,
    "GT Winning Team" text,
    "GTC Winning Team" text,
    "Results" text
)

Question: What circuit had rnd 3?

SQL:
SELECT "Circuit" FROM table_26503 WHERE "Rnd" = '3'
Schema:
CREATE TABLE table_66678 (
    "Date(s) Released" text,
    "Polling institute" text,
    "Nationalist" text,
    "Labour" text,
    "Democratic Alternative" text,
    "Undecided/ No answer" text,
    "Lead" text
)

Question: Which date released had a Democratic Alternative value of 1% and Labour of 34%?

SQL:
SELECT "Date(s) Released" FROM table_66678 WHERE "Democratic Alternative" = '1%' AND "Labour" = '34%'
Schema:
CREATE TABLE table_68453 (
    "Date" text,
    "Tournament" text,
    "Surface" text,
    "Opponent" text,
    "Score" text
)

Question: What was the score in the match against Kim Tiilikainen?

SQL:
SELECT "Score" FROM table_68453 WHERE "Opponent" = 'kim tiilikainen'
Schema:
CREATE TABLE table_26575 (
    "Processor" text,
    "Brand name" text,
    "Model (list)" text,
    "Cores" real,
    "L2 Cache" text,
    "Socket" text,
    "TDP" text
)

Question: What is the wattage/TDP associated with model name 4x0?

SQL:
SELECT "TDP" FROM table_26575 WHERE "Model (list)" = '4x0'
Schema:
CREATE TABLE table_name_86 (
    music_director VARCHAR,
    year INTEGER
)

Question: Name a music director, belonging to a year after 2003?

SQL:
SELECT music_director FROM table_name_86 WHERE year > 2003
Schema:
CREATE TABLE Lives_in (
    stuid INTEGER,
    dormid INTEGER,
    room_number INTEGER
)

CREATE TABLE Dorm (
    dormid INTEGER,
    dorm_name VARCHAR(20),
    student_capacity INTEGER,
    gender VARCHAR(1)
)

CREATE TABLE Has_amenity (
    dormid INTEGER,
    amenid INTEGER
)

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 Dorm_amenity (
    amenid INTEGER,
    amenity_name VARCHAR(25)
)

Question: Find the average age of students living in each city with a bar chart.

SQL:
SELECT city_code, AVG(Age) FROM Student GROUP BY city_code
Schema:
CREATE TABLE elimination (
    elimination_id text,
    wrestler_id text,
    team text,
    eliminated_by text,
    elimination_move text,
    time text
)

CREATE TABLE wrestler (
    wrestler_id number,
    name text,
    reign text,
    days_held text,
    location text,
    event text
)

Question: Which teams had more than 3 eliminations?

SQL:
SELECT team FROM elimination GROUP BY team HAVING COUNT(*) > 3

Question: What are the reigns and days held of all wrestlers?

SQL:
SELECT reign, days_held FROM wrestler
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 microlab (
    microlabid number,
    patientunitstayid number,
    culturesite text,
    organism text,
    culturetakentime time
)

CREATE TABLE lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime time
)

CREATE TABLE allergy (
    allergyid number,
    patientunitstayid number,
    drugname text,
    allergyname text,
    allergytime 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 vitalperiodic (
    vitalperiodicid number,
    patientunitstayid number,
    temperature number,
    sao2 number,
    heartrate number,
    respiration number,
    systemicsystolic number,
    systemicdiastolic number,
    systemicmean number,
    observationtime time
)

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

CREATE TABLE treatment (
    treatmentid number,
    patientunitstayid number,
    treatmentname text,
    treatmenttime time
)

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

Question: what was the first drug that was prescribed to patient 030-56105 through im route in 03/last year?

SQL:
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-56105')) AND medication.routeadmin = 'im' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', medication.drugstarttime) = '03' ORDER BY medication.drugstarttime LIMIT 1
Schema:
CREATE TABLE table_44583 (
    "Class" text,
    "Part 1" text,
    "Part 2" text,
    "Part 3" text,
    "Part 4" text,
    "Verb meaning" text
)

Question: What is the verb meaning for Saugen in part 1?

SQL:
SELECT "Verb meaning" FROM table_44583 WHERE "Part 1" = 'saugen'
Schema:
CREATE TABLE table_name_56 (
    date VARCHAR,
    away_team VARCHAR
)

Question: What date did the away team Mansfield Town play?

SQL:
SELECT date FROM table_name_56 WHERE away_team = "mansfield town"
Schema:
CREATE TABLE allergy (
    allergyid number,
    patientunitstayid number,
    drugname text,
    allergyname text,
    allergytime 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 treatment (
    treatmentid number,
    patientunitstayid number,
    treatmentname text,
    treatmenttime time
)

CREATE TABLE medication (
    medicationid number,
    patientunitstayid number,
    drugname text,
    dosage text,
    routeadmin text,
    drugstarttime time,
    drugstoptime time
)

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

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

CREATE TABLE lab (
    labid number,
    patientunitstayid number,
    labname text,
    labresult number,
    labresulttime time
)

CREATE TABLE vitalperiodic (
    vitalperiodicid number,
    patientunitstayid number,
    temperature number,
    sao2 number,
    heartrate number,
    respiration number,
    systemicsystolic number,
    systemicdiastolic number,
    systemicmean number,
    observationtime time
)

Question: count the number of patients who were diagnosed with valvular stenosis - aortic but did not come back to hospital within 2 months until 1 year ago.

SQL:
SELECT (SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'valvular stenosis - aortic' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t1) - (SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'valvular stenosis - aortic' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 JOIN patient ON t2.uniquepid = patient.uniquepid WHERE t2.diagnosistime < patient.hospitaladmittime AND DATETIME(patient.hospitaladmittime) <= DATETIME(CURRENT_TIME(), '-1 year') AND DATETIME(patient.hospitaladmittime) BETWEEN DATETIME(t2.diagnosistime) AND DATETIME(t2.diagnosistime, '+2 month'))
Schema:
CREATE TABLE table_17914 (
    "Team" text,
    "Location" text,
    "Stadium" text,
    "Founded" real,
    "Joined" real,
    "Head Coach" text,
    "Captain" text
)

Question: When was the team, whose captain is Matt Smith, founded?

SQL:
SELECT "Founded" FROM table_17914 WHERE "Captain" = 'Matt Smith'
Schema:
CREATE TABLE Room (
    RoomNumber INTEGER,
    RoomType VARCHAR(30),
    BlockFloor INTEGER,
    BlockCode INTEGER,
    Unavailable BOOLEAN
)

CREATE TABLE Affiliated_With (
    Physician INTEGER,
    Department INTEGER,
    PrimaryAffiliation BOOLEAN
)

CREATE TABLE Appointment (
    AppointmentID INTEGER,
    Patient INTEGER,
    PrepNurse INTEGER,
    Physician INTEGER,
    Start DATETIME,
    End DATETIME,
    ExaminationRoom TEXT
)

CREATE TABLE Department (
    DepartmentID INTEGER,
    Name VARCHAR(30),
    Head INTEGER
)

CREATE TABLE On_Call (
    Nurse INTEGER,
    BlockFloor INTEGER,
    BlockCode INTEGER,
    OnCallStart DATETIME,
    OnCallEnd DATETIME
)

CREATE TABLE Stay (
    StayID INTEGER,
    Patient INTEGER,
    Room INTEGER,
    StayStart DATETIME,
    StayEnd DATETIME
)

CREATE TABLE Physician (
    EmployeeID INTEGER,
    Name VARCHAR(30),
    Position VARCHAR(30),
    SSN INTEGER
)

CREATE TABLE Procedures (
    Code INTEGER,
    Name VARCHAR(30),
    Cost REAL
)

CREATE TABLE Trained_In (
    Physician INTEGER,
    Treatment INTEGER,
    CertificationDate DATETIME,
    CertificationExpires DATETIME
)

CREATE TABLE Patient (
    SSN INTEGER,
    Name VARCHAR(30),
    Address VARCHAR(30),
    Phone VARCHAR(30),
    InsuranceID INTEGER,
    PCP INTEGER
)

CREATE TABLE Undergoes (
    Patient INTEGER,
    Procedures INTEGER,
    Stay INTEGER,
    DateUndergoes DATETIME,
    Physician INTEGER,
    AssistingNurse INTEGER
)

CREATE TABLE Block (
    BlockFloor INTEGER,
    BlockCode INTEGER
)

CREATE TABLE Prescribes (
    Physician INTEGER,
    Patient INTEGER,
    Medication INTEGER,
    Date DATETIME,
    Appointment INTEGER,
    Dose VARCHAR(30)
)

CREATE TABLE Medication (
    Code INTEGER,
    Name VARCHAR(30),
    Brand VARCHAR(30),
    Description VARCHAR(30)
)

CREATE TABLE Nurse (
    EmployeeID INTEGER,
    Name VARCHAR(30),
    Position VARCHAR(30),
    Registered BOOLEAN,
    SSN INTEGER
)

Question: List the physicians' employee ids together with their primary affiliation departments' ids. Plot them as scatter chart.

SQL:
SELECT Physician, Department FROM Affiliated_With WHERE PrimaryAffiliation = 1
Schema:
CREATE TABLE table_22824324_2 (
    three_pointers INTEGER,
    rebounds VARCHAR
)

Question: What is the lowest number of three pointers in games where the number of rebounds was 178?

SQL:
SELECT MIN(three_pointers) FROM table_22824324_2 WHERE rebounds = 178
Schema:
CREATE TABLE table_62130 (
    "Year" real,
    "Grand Slam" text,
    "Round" text,
    "Winner" text,
    "Loser" text
)

Question: What is the grand slam in 1987, when round shows first round, and Ivan Lendl won?

SQL:
SELECT "Grand Slam" FROM table_62130 WHERE "Year" = '1987' AND "Round" = 'first round' AND "Winner" = 'ivan lendl'
Schema:
CREATE TABLE faculty (
    faculty INTEGER,
    YEAR VARCHAR
)

Question: How many faculty is there in total in the year of 2002?

SQL:
SELECT SUM(faculty) FROM faculty WHERE YEAR = 2002
Schema:
CREATE TABLE table_56945 (
    "Street" text,
    "West" text,
    "East" text,
    "# of lanes" text,
    "Traffic direction" text
)

Question: What is the traffic direction of 70th street?

SQL:
SELECT "Traffic direction" FROM table_56945 WHERE "Street" = '70th street'
Schema:
CREATE TABLE table_37988 (
    "School" text,
    "Team Name" text,
    "Town" text,
    "County" text,
    "School Enrollment (2008\u201310)" real,
    "Football?" text
)

Question: What school had a team name of the Trojans?

SQL:
SELECT "School" FROM table_37988 WHERE "Team Name" = 'trojans'
Schema:
CREATE TABLE table_16577990_1 (
    tree_species VARCHAR,
    central_forest_reserve VARCHAR
)

Question: How many tree species are in the kitechura reserve?

SQL:
SELECT tree_species FROM table_16577990_1 WHERE central_forest_reserve = "Kitechura"
Schema:
CREATE TABLE table_12013 (
    "Rider" text,
    "Horse" text,
    "Faults" text,
    "Round 1 + 2A Points" text,
    "Total" real
)

Question: Tell me the horse when the faults are 9 and the total is 46.36

SQL:
SELECT "Horse" FROM table_12013 WHERE "Faults" = '9' AND "Total" = '46.36'
Schema:
CREATE TABLE table_name_69 (
    total INTEGER,
    gold VARCHAR,
    rank VARCHAR
)

Question: What average total has 0 as the gold, with 6 as the rank?

SQL:
SELECT AVG(total) FROM table_name_69 WHERE gold = 0 AND rank = "6"
Schema:
CREATE TABLE tryout (
    pid number,
    cname text,
    ppos text,
    decision text
)

CREATE TABLE player (
    pid number,
    pname text,
    ycard text,
    hs number
)

CREATE TABLE college (
    cname text,
    state text,
    enr number
)

Question: What are the different names of the colleges involved in the tryout in alphabetical order?

SQL:
SELECT DISTINCT cname FROM tryout ORDER BY cname
Schema:
CREATE TABLE table_name_3 (
    place VARCHAR,
    score VARCHAR
)

Question: what is the place when the score is 68-70-68=206?

SQL:
SELECT place FROM table_name_3 WHERE score = 68 - 70 - 68 = 206
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 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 jobs (
    JOB_ID varchar(10),
    JOB_TITLE varchar(35),
    MIN_SALARY decimal(6,0),
    MAX_SALARY decimal(6,0)
)

CREATE TABLE countries (
    COUNTRY_ID varchar(2),
    COUNTRY_NAME varchar(40),
    REGION_ID decimal(10,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 regions (
    REGION_ID decimal(5,0),
    REGION_NAME varchar(25)
)

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

Question: For those employees who do not work in departments with managers that have ids between 100 and 200, a bar chart shows the distribution of job_id and commission_pct , order in ascending by the total number.

SQL:
SELECT JOB_ID, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY COMMISSION_PCT
Schema:
CREATE TABLE table_204_32 (
    id number,
    "season" number,
    "division" text,
    "w-l" text,
    "finish" text,
    "home" text,
    "road" text,
    "gf" number,
    "ga" number,
    "coach" text,
    "playoffs" text,
    "avg attendance" number
)

Question: what year did the rush allow the most goals ?

SQL:
SELECT "season" FROM table_204_32 ORDER BY "ga" DESC LIMIT 1
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 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 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)
)

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, draw a bar chart about the distribution of hire_date and the average of manager_id bin hire_date by weekday, and I want to order from low to high by the y axis.

SQL:
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY AVG(MANAGER_ID)
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 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 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
)

Question: How many of the female patients belonged to a black/cape verdean ethnic origin?

SQL:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.gender = "F" AND demographic.ethnicity = "BLACK/CAPE VERDEAN"
Schema:
CREATE TABLE Movie (
    mID int,
    title text,
    year int,
    director text
)

CREATE TABLE Reviewer (
    rID int,
    name text
)

CREATE TABLE Rating (
    rID int,
    mID int,
    stars int,
    ratingDate date
)

Question: Return a bar chart on how many movie reviews does each director get?, and order in asc by the bars.

SQL:
SELECT director, COUNT(*) FROM Movie AS T1 JOIN Rating AS T2 ON T1.mID = T2.mID GROUP BY T1.director ORDER BY director
Schema:
CREATE TABLE table_name_55 (
    week INTEGER,
    attendance VARCHAR
)

Question: Total weeks of 49,980 attendance?

SQL:
SELECT SUM(week) FROM table_name_55 WHERE attendance = 49 OFFSET 980
Schema:
CREATE TABLE table_name_41 (
    Id VARCHAR
)

Question: Name the 2008 for 2012 of sf

SQL:
SELECT 2008 FROM table_name_41 WHERE 2012 = "sf"
Schema:
CREATE TABLE table_203_694 (
    id number,
    "#" number,
    "name" text,
    "took office" text,
    "left office" text,
    "party" text
)

Question: nejat konuk and dervi &#351; ero &#287; lu are from which party ?

SQL:
SELECT "party" FROM table_203_694 WHERE "name" IN ('nejat konuk', 'dervis eroglu')
Schema:
CREATE TABLE table_18600760_20 (
    ansi_code VARCHAR,
    latitude VARCHAR
)

Question: How many ansi codes are there for longitude 46.415037?

SQL:
SELECT COUNT(ansi_code) FROM table_18600760_20 WHERE latitude = "46.415037"