lianghsun/bird-text2sql-bench huggingface dataset:
### Database Schema
CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
)

CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
)

CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
)

CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
)

CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

### Question
What percentage of complaints are from the elderly?

### Hint
elder refers to age < = 65; percentage refers to divide(sum(age < = 65) , count(client_id)) * 100%

### SQL
SELECT CAST(SUM(CASE WHEN T1.age > 65 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.age) FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID
### Database Schema
CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
)

CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
)

CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
)

CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
)

CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

### Question
Calculate the percentage of male clients from Indianapolis City.

### Hint
male refers to sex = 'Male'; Indianapolis City refers to city = 'Indianapolis'; percentage = divide(count(client_id where sex = 'Male' and city = 'Indianapolis') , count(client_id where city = 'Indianapolis')) * 100%

### SQL
SELECT CAST(SUM(CASE WHEN sex = 'Male' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(client_id) FROM client WHERE city = 'Indianapolis'
### Database Schema
CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
)

CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
)

CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
)

CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
)

CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

### Question
Among the teenager clients who use Google account and Microsoft account, which group of client is more than the other?

### Hint
teenager refers to 13 < age < = 19; Google account refers to email like '%@gmail.com'; Microsoft account refers to email like '%@outlook.com'

### SQL
SELECT CASE WHEN SUM(CASE WHEN email LIKE '%@gmail.com' THEN 1 ELSE 0 END) > SUM(CASE WHEN email LIKE '%@outlook.com' THEN 1 ELSE 0 END) THEN 'Google account' ELSE 'Microsoft account' END FROM client WHERE age BETWEEN 13 AND 19
### Database Schema
CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
)

CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
)

CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
)

CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
)

CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

### Question
What is the full name of client whose email address is emily.garcia43@outlook.com?

### Hint
full name refers to first middle last

### SQL
SELECT first, middle, last FROM client WHERE email = 'emily.garcia43@outlook.com'
### Database Schema
CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
)

CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
)

CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
)

CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
)

CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

### Question
What is the first name of clients who have the highest priority?

### Hint
first name refers to first; highest priority refers to priority = 2

### SQL
SELECT T1.first FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.priority = ( SELECT MAX(priority) FROM callcenterlogs )
### Database Schema
CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
)

CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
)

CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
)

CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
)

CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

### Question
List down the email of client whose complaint is type "PS".

### SQL
SELECT T1.email FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T2.type = 'PS'
### Database Schema
CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
)

CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
)

CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
)

CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
)

CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

### Question
Among the elderlies, state the last name of whose complaint is handled in server YIFAT?

### Hint
elder refers to age < = 65; last name refers to last

### SQL
SELECT T1.last FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.age > 65 AND T2.server = 'YIFAT'
### Database Schema
CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
)

CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
)

CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
)

CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
)

CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
)

### Question
How many clients who live in New York City have the complaint outcome as "AGENT"?

### Hint
New York City refers to city = 'New York City'

### SQL
SELECT COUNT(T2.`rand client`) FROM client AS T1 INNER JOIN callcenterlogs AS T2 ON T1.client_id = T2.`rand client` WHERE T1.city = 'New York City' AND T2.outcome = 'AGENT'