Dludora/DAIL-BIRD huggingface dataset:
/* Given the following database schema: */
CREATE TABLE "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
)

CREATE TABLE "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
)

CREATE TABLE "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
)

/* Answer the following: In the Venus and Adonis, what is the description of the last scene listed? Venus and Adonis refers to Title = 'Venus and Adonis'; last scene refers to max(Scene) */
SELECT 
SELECT T2.Description FROM works AS T1 RIGHT JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.Title = 'Venus and Adonis' ORDER BY T2.Scene DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
)

CREATE TABLE "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
)

CREATE TABLE "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
)

/* Answer the following: In Act 1 Scene 2 of the Twelfth Night, what is the total number of of lines said by Viola? Twelfth Night refers to Title = 'Twelfth Night'; total number of lines said by Viola refers to count(character_id) where CharName = 'Viola' */
SELECT 
SELECT COUNT(T4.id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T2.Act = 1 AND T2.Scene = 2 AND T4.id = 1238 AND T4.CharName = 'Viola' AND T1.Title = 'Twelfth Night'
/* Given the following database schema: */
CREATE TABLE "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
)

CREATE TABLE "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
)

CREATE TABLE "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
)

/* Answer the following: What is the character and work ID of the text "Fear not thou, man, thou shalt lose nothing here."? character refers to chapter_id; text "Fear not thou, man, thou shalt lose nothing here."  refers to PlainText = 'Fear not thou, man, thou shalt lose nothing here.' */
SELECT 
SELECT T2.character_id, T1.work_id FROM chapters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.chapter_id WHERE T2.PlainText = 'Fear not thou, man, thou shalt lose nothing here.'
/* Given the following database schema: */
CREATE TABLE "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
)

CREATE TABLE "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
)

CREATE TABLE "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
)

/* Answer the following: What is the chapter description where the paragraph "What, wilt thou hear some music, my sweet love?" belongs? paragraph "What, wilt thou hear some music, my sweet love?" refers to  PlainText = 'What, wilt thou hear some music, my sweet love?' */
SELECT 
SELECT T1.id, T1.Description FROM chapters AS T1 INNER JOIN paragraphs AS T2 ON T1.id = T2.chapter_id WHERE T2.PlainText = 'What, wilt thou hear some music, my sweet love?'
/* Given the following database schema: */
CREATE TABLE "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
)

CREATE TABLE "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
)

CREATE TABLE "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
)

/* Answer the following: List the scene numbers involving the character named Sir Toby Belch in the Twelfth Night. scene numbers refers to Scene; character named Sir Toby Belch refers to CharName = 'Sir Toby Belch'; in the Twelfth Night refers to Title = 'Twelfth Night' */
SELECT 
SELECT DISTINCT T2.Scene FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T1.Title = 'Twelfth Night' AND T4.CharName = 'Sir Toby Belch'
/* Given the following database schema: */
CREATE TABLE "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
)

CREATE TABLE "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
)

CREATE TABLE "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
)

/* Answer the following: In Shakespeare's works before 1600, list down the title of the tragic story he had written that involved a character named "Tybalt". works before 1600 refers to DATE < 1600; tragic story refers to GenreType = 'Tragedy'; character named "Tybalt" refers to CharName = 'Tybalt' */
SELECT 
SELECT DISTINCT T1.title FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T1.DATE < 1600 AND T1.GenreType = 'Tragedy' AND T4.CharName = 'Tybalt'
/* Given the following database schema: */
CREATE TABLE "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
)

CREATE TABLE "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
)

CREATE TABLE "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
)

/* Answer the following: List the chapter ID of the works with a year greater than the 89% of average year of all listed works of Shakespeare. a year greater than the 89% of average year refers to DATE > multiply(divide(SUM(DATE) , COUNT(DATE)), 0.89) */
SELECT 
SELECT T2.id FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.DATE > ( SELECT AVG(DATE) FROM works ) * 0.89
/* Given the following database schema: */
CREATE TABLE "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
)

CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
)

CREATE TABLE "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
)

CREATE TABLE "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
)

/* Answer the following: Among the comedy works of Shakespeare, what is the percentage of his works with a character named "antonio"? comedy works refers to GenreType = 'Comedy'; a character named "antonio" refers to CharName = 'antonio'; percentage = divide(sum(CharName = 'Antonio'), count(CharName)) as percentage */
SELECT 
SELECT CAST(SUM(IIF(T4.CharName = 'antonio', 1, 0)) AS REAL) * 100 / COUNT(T1.id) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id INNER JOIN paragraphs AS T3 ON T2.id = T3.chapter_id INNER JOIN characters AS T4 ON T3.character_id = T4.id WHERE T1.GenreType = 'Comedy'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Among the cars with 8 cylinders, what is the name of the one that's the most expensive? with 8 cylinders refers to cylinders = 8; name of the car refers to car_name; the most expensive refers to max(price) */
SELECT 
SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.cylinders = 8 ORDER BY T2.price DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Among the cars over 3000lbs, how many of them cost less than $30000? over 3000lbs refers to weight > 3000; cost less than $30000 refers to price < 30000 */
SELECT 
SELECT COUNT(T1.car_name) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.weight > 3000 AND T2.price < 30000
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What is the acceleration of the most expensive car? the most expensive refers to max(price) */
SELECT 
SELECT T1.acceleration FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T2.price DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: How much US dollars does a Ford Torino cost? cost refers to price; Ford Torino refers to car_name = 'ford torino' */
SELECT 
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'ford torino'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What was the origin country of the car model ford torino produced in 1970? origin country refers to country; Ford Torino refers to car_name = 'ford torino'; produced in 1970 refers to model_year = 1970 */
SELECT 
SELECT T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T1.car_name = 'ford torino' AND T2.model_year = 1970
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Among the car models introduced in the market in 1970, how many of them have the USA as their origin country? introduced in the market in 1970 refers to model_year = 1970; have the USA as origin country refers to country = 'USA' */
SELECT 
SELECT COUNT(*) FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T1.model_year = 1970 AND T2.country = 'USA'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Please list the names of all the car models whose origin country is the USA. name of car model refers to car_name; origin country is the USA refers to country = 'USA' */
SELECT 
SELECT DISTINCT T1.car_name FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T2.country = T3.origin WHERE T3.country = 'USA'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Please list the names of the top 3 most expensive cars. name of the car refers to car_name; the most expensive refers to max(price) */
SELECT 
SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T2.price DESC LIMIT 3
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Please list all the years in which the car model Chevrolet Impala was introduced in the market. year refers to model_year; Chevrolet Impala refers to car_name = 'chevrolet impala' */
SELECT 
SELECT DISTINCT T1.model_year FROM production AS T1 INNER JOIN data AS T2 ON T1.ID = T2.ID WHERE T2.car_name = 'chevrolet impala'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Among the cars with an acceleration of over 10 miles per squared hour, how many of them cost more than $20000 and less than $30000? an acceleration of over 10 miles per squared hour refers to acceleration > 10; cost more than $20000 and less than $30000 refers to price < 30000 AND price > 20000 */
SELECT 
SELECT COUNT(*) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.acceleration > 10 AND T2.price BETWEEN 20000 AND 30000
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Please list the weights of all the cars with the price over $40000. price over $40000 refers to price > 40000 */
SELECT 
SELECT T1.weight FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price > 40000
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What is the maximum acceleration of a car with price over $40000? the maximum acceleration refers to max(acceleration); price over $40000 refers to price > 40000 */
SELECT 
SELECT MAX(T1.acceleration) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price > 40000
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What is the average price of cars with 8 cylinders? with 8 cylinders refers to cylinders = 8; average price = avg(price) where cylinders = 8 */
SELECT 
SELECT AVG(T2.price) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.cylinders = 8
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What is the maximum sweep volume of a car that costs less than $30000? cost less than $30000 refers to price < 30000; the maximum sweep volume = max(divide(displacement, cylinders)) where price < 30000 */
SELECT 
SELECT MAX(T1.displacement / T1.cylinders) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price < 30000
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: How many cars in the database are originated from Europe? originated from Europe refers to country = 'Europe' */
SELECT 
SELECT COUNT(*) FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T2.country = 'Europe'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Show the origin country of Chevrolet Malibu. origin country refers to country; Chevrolet Malibu refers to car_name = 'chevrolet malibu' */
SELECT 
SELECT T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T1.car_name = 'chevrolet malibu'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What are the miles per gallon of the most expensive car? miles per gallon refers to mpg; the most expensive refers to max(price) */
SELECT 
SELECT T1.mpg FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T2.price DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Tell the origin country of car no.382. origin country refers to country; car no.382 refers to ID = 382 */
SELECT 
SELECT DISTINCT T2.country FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T1.ID = 382
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Which is the origin country of the $44274.40748 car? origin country refers to country; the $44274.40748 car refers to price = 44274.40748 */
SELECT 
SELECT T3.country FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T1.price = 44274.40748
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: How much is the Volkswagen Dasher with 14.1 mph acceleration? cost refers to price; Volkswagen Dasher refers to car_name = 'volkswagen dasher'; 14.1 mph acceleration refers to acceleration = 14.1 */
SELECT 
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'volkswagen dasher' AND T1.acceleration = '14.1'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Provide the engine displacement status of the $37443.85589 car. engine displacement status refers to displacement; the $37443.85589 car refers to price = 37443.85589 */
SELECT 
SELECT T1.displacement FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = '37443.85589'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: When was the $32650.65157 car introduced to the market? State the year. the $32650.65157 car refers to price = 32650.65157; year refers to model */
SELECT 
SELECT T1.model FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = '32650.65157'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Provide the price of the only Toyota Corona hardtop in the database. Toyota Corona hardtop refers to car_name = 'toyota corona hardtop' */
SELECT 
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'toyota corona hardtop'
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: How many cylinders does the cheapest car have? the cheapest car refers to min(price) */
SELECT 
SELECT T1.cylinders FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY price ASC LIMIT 1
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Which car in the database provides the best crash protection based on its weight? How much is it? the best crash protection refers to max(weight); cost refers to price */
SELECT 
SELECT T1.ID, T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T1.weight DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: State the origin country of the fastest car in the database. origin country refers to country; the fastest refers to max(horsepower) */
SELECT 
SELECT T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country ORDER BY T1.horsepower DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What is the percentage of Japanese cars in the database? Japanese car refers to country = 'Japan'; percentage = divide(count(ID where country = 'Japan'), count(ID)) * 100% */
SELECT 
SELECT CAST(SUM(CASE WHEN T2.country = 'Japan' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: Calculate the swept volume of the $34538.97449 car. sweep volume = divide(displacement, cylinders); the $34538.97449 car refers to price = 34538.97449 */
SELECT 
SELECT T1.displacement / T1.cylinders FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = 34538.97449
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What is the name of the most expensive car? name of the car refers to car_name; the most expensive refers to max(price) */
SELECT 
SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T2.price DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: How many cars were released in the USA in 1981? in the USA refers to country = 'USA'; in 1981 refers to model_year = 1981 */
SELECT 
SELECT COUNT(*) FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T2.country = 'USA' AND T1.model_year = 1981
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: How much is the car with the highest sweep volume? cost refers to price; the highest sweep volume refers to max(divide(displacement, cylinders)) */
SELECT 
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID ORDER BY T1.displacement / T1.cylinders DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
)

CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
)

CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
)

CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
)

/* Answer the following: What is the fastest car made by Japan? the fastest refers to max(horsepower); made by Japan refers to country = 'Japan'; name of the car refers to car_name */
SELECT 
SELECT T1.car_name FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T3.country = 'Japan' ORDER BY T1.horsepower DESC LIMIT 1