lianghsun/bird-text2sql-bench huggingface dataset:
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Calculate the percentage of voice actors whose main character in the movie is in the Drama genre.

### Hint
DIVIDE(COUNT(voice-actor where genre = 'Drama'), COUNT(voice-actor)) as percentage;

### SQL
SELECT CAST(COUNT(CASE WHEN T1.genre = 'Drama' THEN T3.`voice-actor` ELSE NULL END) AS REAL) * 100 / COUNT(T3.`voice-actor`) FROM movies_total_gross AS T1 INNER JOIN characters AS T2 ON T1.movie_title = T2.movie_title INNER JOIN `voice-actors` AS T3 ON T3.movie = T1.movie_title
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Name the first movie released by Disney.

### Hint
The first movie released refers to movie_title where substr(release_date, length(release_date) - 1, length(release_date)) asc limit 1;

### SQL
SELECT movie_title FROM characters ORDER BY SUBSTR(release_date, LENGTH(release_date) - 1, LENGTH(release_date)) ASC LIMIT 1
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
How many movies were released by Disney between 2010 and 2016?

### Hint
Movies refer to movie_title; released between 2010 and 2016 refers to substr(release_date, length(release_date) - 1, length(release_date)) between '10' and '16';

### SQL
SELECT COUNT(movie_title) FROM characters WHERE SUBSTR(release_date, LENGTH(release_date) - 1, LENGTH(release_date)) BETWEEN '10' AND '16'
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Who was the first ever Disney villain?

### Hint
the first ever villian is villian that was released before all others in time which refers to substr(release_date, length(release_date) - 1, length(release_date)) desc limit 1;

### SQL
SELECT villian FROM characters ORDER BY SUBSTR(release_date, LENGTH(release_date) - 1, LENGTH(release_date)) DESC LIMIT 1
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
What is Disney's highest grossing action movie?

### Hint
action movie refers to movie_title where genre = 'Action'; highest grossing movie refers to MAX(total_gross)

### SQL
SELECT movie_title FROM movies_total_gross WHERE genre = 'Action' ORDER BY CAST(REPLACE(trim(total_gross, '$'), ',', '') AS REAL) DESC LIMIT 1
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Which actor voices Akela from The Jungle Book?

### Hint
Akela refers character = 'Akela'; which actor voices refers to voice-actor;

### SQL
SELECT `voice-actor` FROM `voice-actors` WHERE character = 'Akela'
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Determine Disney's total box office gross between 2010 and 2016.

### Hint
between 2010 and 2016 refers to Year between 2010 and 2016;

### SQL
SELECT SUM(Total) FROM revenue WHERE `Year` BETWEEN 2010 AND 2016
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Name the main character of Disney's most popular adventure movie based on its inflation-adjusted gross.

### Hint
adventure movie refers to genre = 'Adventure'; the main character of the movie refers to hero; most popular movie based on its inflation-adjusted gross refers to where MAX(inflation_adjusted_gross);

### SQL
SELECT T2.hero FROM movies_total_gross AS T1 INNER JOIN characters AS T2 ON T1.movie_title = T2.movie_title WHERE T1.genre = 'Adventure' ORDER BY CAST(REPLACE(trim(T1.inflation_adjusted_gross, '$'), ',', '') AS REAL) DESC LIMIT 1
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Name the director of Disney's lowest grossing movie.

### Hint
lowest grossing movie refers to movie_title where MIN(total_gross);

### SQL
SELECT T2.director FROM movies_total_gross AS T1 INNER JOIN director AS T2 ON T1.movie_title = T2.name ORDER BY CAST(REPLACE(trim(T1.total_gross, '$'), ',', '') AS REAL) ASC LIMIT 1
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Find out what proportion of total revenue Walt Disney Parks and Resorts received in 2010.

### Hint
DIVIDE(Walt Disney Parks and Resorts where year = 2010), SUM(year = 2010) as percentage;

### SQL
SELECT SUM(`Walt Disney Parks and Resorts`) / SUM(Total) * 100 FROM revenue WHERE year = 2010
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Determine the average gross for Disney's PG-13-rated action movies.

### Hint
DIVIDE(SUM(total_gross where genre = 'Action' and MPAA_rating = 'PG-13'), COUNT(movie_title where genre = 'Action' and MPAA_rating = 'PG-13'));

### SQL
SELECT SUM(CAST(REPLACE(trim(total_gross, '$'), ',', '') AS REAL)) / COUNT(movie_title) FROM movies_total_gross WHERE MPAA_rating = 'PG-13'
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
How many voice-actors were involved in the Bambi movie?

### Hint
Bambi is the name of the movie which refers to movie = 'Bambi';

### SQL
SELECT COUNT(DISTINCT 'voice-actor') FROM `voice-actors` WHERE movie = 'Bambi'
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
Find the estimated inflation rate that was used to adjust the 1995 box office revenue for Disney's films.

### Hint
DIVIDE(inflation_adjusted_gross, total_gross) as percentage where substr(release_date, length(release_date) - 3, length(release_date)) = '1995';

### SQL
SELECT SUM(CAST(REPLACE(trim(inflation_adjusted_gross, '$'), ',', '') AS REAL)) / SUM(CAST(REPLACE(trim(total_gross, '$'), ',', '') AS REAL)) FROM movies_total_gross WHERE SUBSTR(release_date, LENGTH(release_date) - 3, LENGTH(release_date)) = '1995' GROUP BY SUBSTR(release_date, LENGTH(release_date) - 3, LENGTH(release_date)) = '1995'
### Database Schema
CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
)

CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
)

CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
)

CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
)

CREATE TABLE "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
)

### Question
What is the difference in the current gross of Cars and its sequel, Cars 2? Which movie is more popular?

### Hint
SUBTRACT(inflation_adjusted_gross where movie_title = 'Cars', inflation_adjusted_gross where movie_title = 'Cars 2'); more popular movie refers to movie_title where MAX(inflation_adjusted_gross);

### SQL
SELECT SUM(CASE WHEN movie_title = 'Cars' THEN CAST(REPLACE(trim(inflation_adjusted_gross, '$'), ',', '') AS REAL) ELSE 0 END), SUM(CASE WHEN movie_title = 'Cars 2' THEN CAST(REPLACE(trim(inflation_adjusted_gross, '$'), ',', '') AS REAL) ELSE 0 END) FROM movies_total_gross