Dludora/DAIL-BIRD huggingface dataset:
/* 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 times was Ford Maverick introduced to the market? Ford Maverick refers to car_name = 'ford maverick'; */
SELECT 
SELECT COUNT(T2.model_year) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'ford maverick'
/* 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 country produced the most fuel-efficient car? the most fuel-efficient refers to max(mpg) */
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.mpg 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: Which Dodge car is the cheapest? Dodge car refers to car_name LIKE 'dodge%'; the cheapest refers to min(price); name of the car refers to car_name */
SELECT 
SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name LIKE 'dodge%' ORDER BY T2.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: What is the name of the most expensive car that was produced by the USA? name of the car refers to car_name; the most expensive refers to max(price); produced by the USA refers to country = 'USA' */
SELECT 
SELECT T4.car_name FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'USA' ORDER BY T1.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 with an engine displacement of no less than 400 cubic millimeter, how many cars cost at least 30,000? engine displacement of no less than 400 cubic millimeter refers to displacement > 400; cost at least 30,000 refers to price > 30000 */
SELECT 
SELECT COUNT(*) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.displacement > 400 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: Which year did Europe produce the most cars? year refers to model_year; Europe refers to country = 'Europe'; the most cars refers to max(model_year) */
SELECT 
SELECT T1.model_year FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T2.country = 'Europe' GROUP BY T1.model_year ORDER BY COUNT(T1.model_year) 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 is the Peugeot 505s Turbo Diesel? cost refers to price; Peugeot 505s Turbo Diesel refers to car_name = 'peugeot 505s turbo diesel' */
SELECT 
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'peugeot 505s turbo diesel'
/* 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 miles per square hour of the cheapest car produced by the USA? miles per square hour refers to acceleration; the cheapest refers to min(price); produced by the USA refers to country = 'USA' */
SELECT 
SELECT T4.acceleration FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'USA' ORDER BY T1.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 country produced the highest number of cars? Calculate the annual average number of cars that the said country produced from the very start to the present. the highest number of cars refers to max(country); annual average number = divide(count(ID), count(model_year)) */
SELECT 
SELECT T2.country, CAST(COUNT(T1.ID) AS REAL) / COUNT(DISTINCT T1.model_year) FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin GROUP BY T2.country ORDER BY COUNT(T2.country) 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 cars that was produced by Japan among those that have a sweep volume of no less than 30? produced by Japan refers to country = 'Japan'; a sweep volume of no less than 30 refers to divide(displacement, cylinders) > 30; percentage = divide(count(ID where country = 'Japan'), count(ID)) * 100% where divide(displacement, cylinders) > 30 */
SELECT 
SELECT CAST(SUM(CASE WHEN T3.country = 'Japan' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) 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.displacement / T1.cylinders > 30
/* 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: List the name of the cars with model year 1975. name of the car refers to car_name; model year 1975 refers to model_year = 1975 */
SELECT 
SELECT T1.car_name FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T2.model_year = 1975
/* 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 average price of cars from Europe. from Europe refers to country = 'Europe'; average price = avg(price) where country = 'Europe' */
SELECT 
SELECT AVG(T1.price) 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 T3.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: What is the price of the car ID 15? */
SELECT 
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.ID = 15
/* 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 of the cars from Japan weighed less than 3000? from Japan refers to country = 'Japan'; weighed less than 3000 refers to weight < 3000 */
SELECT 
SELECT COUNT(*) FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'Japan' AND T4.weight < 3000
/* 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 produced in year 1973, how many of the cars have horsepower less than 100? produced in year 1973 refers to model_year = 1973; have horsepower less than 100 refers to horsepower < 100 */
SELECT 
SELECT COUNT(*) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T2.model_year = 1973 AND T1.horsepower < 100
/* 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 ID of cars from Japan worth greater than 35000 and have an acceleration of 14. from Japan refers to country = 'Japan'; worth greater than 35000 refers to price > 35000; have an acceleration of 14 refers to acceleration = 14 */
SELECT 
SELECT T4.ID FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'Japan' AND T1.price > 3500 AND T4.acceleration = 14
/* 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: Give the model year of the heaviest car. the heaviest refers to max(weight) */
SELECT 
SELECT T2.model_year FROM data AS T1 INNER JOIN production 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: What is the horsepower and model year of the car named Subaru Dl? the car named Subaru Dl refers to car_name = 'subaru dl' */
SELECT 
SELECT T1.horsepower, T2.model_year FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'subaru dl'
/* 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 originated from Japan, what is the name of the car with the highest price? from Japan refers to country = 'Japan'; name of the car refers to car_name; the highest price refers to max(price) */
SELECT 
SELECT T4.car_name FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T3.country = 'Japan' ORDER BY T1.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: What are the names of the cars worth 20000? name of the car refers to car_name; worth 20000 refers to price = 20000 */
SELECT 
SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price = 20000
/* 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 worth greater than 40000 were from the USA? worth greater than 40000 refers to price > 40000; from the USA refers to country = 'USA' */
SELECT 
SELECT COUNT(*) 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 T3.country = 'USA' AND T1.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: Provide the price and country origin of the car named Ford Maverick. country origin refers to country; Ford Maverick refers to car_name = 'ford maverick' */
SELECT 
SELECT DISTINCT T1.price, 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 INNER JOIN data AS T4 ON T4.ID = T1.ID WHERE T4.car_name = 'ford maverick'
/* 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: List the car's name with a price worth greater than 85% of the average price of all cars. car's name refers to car_name; a price worth greater than 85% of the average price of all cars refers to price > multiply(avg(price), 0.85) */
SELECT 
SELECT T1.car_name FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T2.price * 100 > ( SELECT AVG(price) * 85 FROM price )
/* 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 difference between the number of cars that has a horsepower of 130 with the model year 1970 and model year 1976 a horsepower of 130 refers to horsepower = 130; difference = subtract(count(ID where model_year = 1970), count(ID where model_year = 1976)) where horsepower = 130 */
SELECT 
SELECT SUM(CASE WHEN T2.model_year = 1970 THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.model_year = 1976 THEN 1 ELSE 0 END) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T1.horsepower = 130
/* 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 from Asia, list the IDs of cars that were introduced in 1979. from Asia refers to country = 'Japan'; introduced in 1979 refers to model_year = 1979 */
SELECT 
SELECT T1.ID FROM production AS T1 INNER JOIN country AS T2 ON T1.country = T2.origin WHERE T2.country = 'Japan' AND T1.model_year = 1979
/* 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 country produced the car with the lowest mileage per gallon? the lowest mileage per gallon refers to min(mpg) */
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.mpg 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: Provide the name, model, sweep volume, and introduced year of the car with the best crash protection. car's name refers to car_name; sweep volume = divide(displacement, cylinders); introduced year refers to model_year; the best crash protection refers to max(weight) */
SELECT 
SELECT T1.car_name, T1.model, T1.displacement / T1.cylinders, T2.model_year FROM data AS T1 INNER JOIN production 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: Among the cars introduced in 1977, provide the names and the horse powers of cars from Europe. introduced in 1977 refers to model_year = 1977; car's name refers to car_name; from Europe refers to country = 'Europe' */
SELECT 
SELECT T1.car_name, T1.horsepower 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 T2.model_year = 1977 AND T3.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: Provide the name and model of the car with the highest price. car's name refers to car_name; the highest price refers to max(price) */
SELECT 
SELECT T1.car_name, T1.model 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: What is the price of a Chevrolet Bel Air? Chevrolet Bel Air refers to car_name = 'chevrolet bel air' */
SELECT 
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'chevrolet bel air'
/* 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 per car produced in Japan? produced in Japan refers to country = 'Japan'; average price per car = avg(price) where country = 'Japan' */
SELECT 
SELECT AVG(T1.price) 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 T3.country = 'Japan'
/* 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 country produced the car with the lowest price? the lowest price refers to min(price) */
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 ORDER BY T1.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: Among the cars produced in 1975, provide IDs, names, and producing countries of the cars with the maximum number of cylinders. produced in 1975 refers to model_year = 1975; names refers to car_name; producing countries refers to country; the maximum number of cylinders refers to max(cylinders) */
SELECT 
SELECT T1.ID, T1.car_name, 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 T2.model_year = 1975 ORDER BY 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: Which car is the cheapest? Provide its acceleration, number of cylinders, and producing year. the cheapest refers to min(price); number of cylinders refers to cylinders; producing year refers to model_year */
SELECT 
SELECT T1.acceleration, T1.cylinders, T2.model_year FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN price AS T3 ON T3.ID = T2.ID ORDER BY T3.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: List the names and prices of the cars with model 82 and mileage per gallon of greater than 30. car's name refers to car_name; model 82 refers to model = 82; mileage per gallon of greater than 30 refers to mpg > 30 */
SELECT 
SELECT T2.car_name, T1.price FROM price AS T1 INNER JOIN data AS T2 ON T1.ID = T2.ID WHERE T2.model = 82 AND T2.mpg > 30
/* 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 models of Ford Maverick were produced? Ford Maverick refers to car_name = 'ford maverick' */
SELECT 
SELECT COUNT(DISTINCT T2.model_year) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'ford maverick'
/* 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 percentage of cars that belong to the USA. belong to the USA refers to country = 'USA'; percentage = divide(count(ID where country = 'USA'), count(ID)) * 100% */
SELECT 
SELECT CAST(SUM(CASE WHEN T2.country = 'USA' 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 average production rate per year from 1971 to 1980. Among them, name the cars with a weight of fewer than 1800 lbs. from 1971 to 1980 refers to model_year between 1971 and 1980; average production rate per year = divide(count(ID where model_year between 1971 and 1980), 9); car's name refers to car_name; a weight of fewer than 1800 lbs refers to weight < 1800 */
SELECT 
SELECT CAST(COUNT(T1.ID) AS REAL) / 9 FROM production AS T1 INNER JOIN data AS T2 ON T2.ID = T1.ID WHERE T1.model_year BETWEEN 1971 AND 1980 UNION ALL SELECT DISTINCT T2.car_name FROM production AS T1 INNER JOIN data AS T2 ON T2.ID = T1.ID WHERE T1.model_year BETWEEN 1971 AND 1980 AND T2.weight < 1800
/* 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 model 70 cars? model 70 refers to model = 70; average price = avg(price) where model = 70 */
SELECT 
SELECT AVG(T2.price) FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.model = 70
/* 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 price of Chevrolet Vega 2300? Chevrolet Vega 2300 refers to car_name = 'chevrolet vega 2300' */
SELECT 
SELECT T2.price FROM data AS T1 INNER JOIN price AS T2 ON T1.ID = T2.ID WHERE T1.car_name = 'chevrolet vega 2300'
/* 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 country does Chevy C20 come from? Chevy C20 refers to car_name = 'chevy c20' */
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 = 'chevy c20'