Dludora/DAIL-BIRD huggingface dataset:
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Provide the ingredients that are rationed in the recipe with the highest carbohydrate content. the highest carbohydrate content refers to MAX(carbo) */
SELECT 
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id INNER JOIN Nutrition AS T3 ON T3.recipe_id = T2.recipe_id WHERE T2.max_qty = T2.min_qty ORDER BY T3.carbo DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Name the recipes which can lead to constipation. can lead to constipation refers to iron > 20 */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.iron > 20
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Describe the ingredients in the recipe with the highest vitamin that helps vision in dim light. the highest vitamin that helps vision in dim light refers to MAX(vitamin_a) */
SELECT 
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id INNER JOIN Nutrition AS T3 ON T3.recipe_id = T2.recipe_id ORDER BY T3.vitamin_a DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Provide the ingredients and maximum quantities of the recipe which can serve 7 people. can serve 7 people refers to servings = 7 */
SELECT 
SELECT T3.name, T2.max_qty FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.servings = 7
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Among the recipes from The California Tree Fruit Agreement, calculate the percentage of sodium-free recipes. The California Tree Fruit Agreement is a source; calculation = MULTIPLY(DIVIDE(COUNT(sodium BETWEEN 0 AND 5 THEN recipe_id), COUNT(recipe_id)), 100) */
SELECT 
SELECT CAST(SUM(CASE WHEN T2.sodium < 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.source = 'The California Tree Fruit Agreement'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: List the ingredients which measure in slices. slices refers to unit = 'slice(s)' */
SELECT 
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T2.unit = 'slice(s)'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many recipes can be made with canned dairy? canned dairy is a category */
SELECT 
SELECT COUNT(*) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T1.category = 'canned dairy'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Provide the title and total time of the recipe which can be made with only lima beans. total time refers to total time refers to TOTAL(prep_min, cook_min, stnd_min); lima beans is a name of an ingredient */
SELECT 
SELECT T1.title, T1.prep_min + T1.cook_min + T1.stnd_min FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T3.name = 'lima beans'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Among the recipes with sea bass, how many percent of recipes can serve 10 people and above? sea bass is a name of an ingredient; can serve 10 people and above refers to servings > = 10; calculation = MULTIPLY(DIVIDE(COUNT(servings > = 10 THEN recipe_id)), COUNT(recipe_id), 100) */
SELECT 
SELECT CAST(SUM(CASE WHEN T1.servings >= 10 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T3.name = 'sea bass steak'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How much fat does the Raspberry Chiffon Pie have? Raspberry Chiffon Pie refers to title */
SELECT 
SELECT T2.total_fat FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: What is the percentage calories protein of Raspberry Chiffon Pie? Raspberry Chiffon Pie refers title; percentage calories protein refers to pcnt_cal_prot */
SELECT 
SELECT pcnt_cal_prot FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many ingredients are required to make the Raspberry Chiffon Pie? Raspberry Chiffon Pie refer to title */
SELECT 
SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Raspberry Chiffon Pie'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: List the names of alcohol free recipes. alcohol free refers to alcohol = 0 */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.alcohol = 0
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: What is the average vitamin C amount of all cakes? average vitamin C refers to AVG(vitamin_c); all cakes refers to title LIKE '%cake%' */
SELECT 
SELECT AVG(T1.vitamin_c) FROM Nutrition AS T1 INNER JOIN Recipe AS T2 ON T2.recipe_id = T1.recipe_id WHERE T2.title LIKE '%cake%'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many dairy recipes can serve more than 10 people? dairy recipes refers to category = 'dairy'; serve more than 10 people refers to servings > 10 */
SELECT 
SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T3.category = 'dairy' AND T1.servings > 10
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: List the names of recipes that can lead to constipation. lead to constipation refers to iron > 20 */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.iron > 20
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Which recipe has the highest calories? the highest calories refers to MAX(calories) */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id ORDER BY T2.calories DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many recipes are non-dairy? non-dairy refers to category NOT LIKE '%dairy" */
SELECT 
SELECT COUNT(T2.recipe_id) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T2.ingredient_id = T1.ingredient_id INNER JOIN Nutrition AS T3 ON T3.recipe_id = T2.recipe_id WHERE T1.category NOT LIKE '%dairy%'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: List all the ingredients of Apricot Yogurt Parfaits. Apricot Yogurt Parfaits refers to title */
SELECT 
SELECT T3.name, T3.category FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Apricot Yogurt Parfaits'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Identify recipes with different maximum and minimum quantities. maximum quantities refers to max_qty; minimum quantities refers to max_qty <> min_qty */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.max_qty <> T2.min_qty
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: What ingredients does the longest cooking time recipe have? the longest cooking time refers to MAX(cook_min) */
SELECT 
SELECT T3.name FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id ORDER BY T1.cook_min DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Calculate the percentage of recipes with no cholesterol included and have a cooking time less than 20 minutes among all recipes. no cholesterol refers to cholestrl = 0; cooking time less than 20 minutes refers to cook_min < 20; calculation = MULTIPLY(DIVIDE(COUNT(cholestrl = 0 THEN recipe_id), COUNT(recipe_id)), 100) */
SELECT 
SELECT CAST(SUM(CASE WHEN T1.cook_min < 20 AND T2.cholestrl = 0 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Among all recipes containing cheese, what is the percentage of recipes with calories greater than 200? cheese is a category; calories greater than 200 refers to calories > 200; calculation = MULTIPLY(DIVIDE(COUNT(calories > 200 THEN recipe_id), COUNT(recipe_id)), 100) */
SELECT 
SELECT CAST(SUM(CASE WHEN T4.calories > 200 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id INNER JOIN Nutrition AS T4 ON T4.recipe_id = T1.recipe_id WHERE T3.category = 'cheese'
/* Given the following database schema: */
CREATE TABLE location
(
    locationID   INTEGER
        constraint location_pk
            primary key,
    locationcity TEXT,
    address      TEXT,
    state        TEXT,
    zipcode      INTEGER,
    officephone  TEXT
)

CREATE TABLE position
(
    positionID        INTEGER
        constraint position_pk
            primary key,
    positiontitle     TEXT,
    educationrequired TEXT,
    minsalary         TEXT,
    maxsalary         TEXT
)

CREATE TABLE employee
(
    ssn         TEXT
            primary key,
    lastname    TEXT,
    firstname   TEXT,
    hiredate    TEXT,
    salary      TEXT,
    gender      TEXT,
    performance TEXT,
    positionID  INTEGER,
    locationID  INTEGER,
    foreign key (locationID) references location(locationID),
    foreign key (positionID) references position(positionID)
)

/* Answer the following: Which employee has the highest salary? Please give his or her full name. the highest salary refers to MAX(salary); full name = firstname, lastname */
SELECT 
SELECT firstname, lastname FROM employee ORDER BY salary DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE location
(
    locationID   INTEGER
        constraint location_pk
            primary key,
    locationcity TEXT,
    address      TEXT,
    state        TEXT,
    zipcode      INTEGER,
    officephone  TEXT
)

CREATE TABLE position
(
    positionID        INTEGER
        constraint position_pk
            primary key,
    positiontitle     TEXT,
    educationrequired TEXT,
    minsalary         TEXT,
    maxsalary         TEXT
)

CREATE TABLE employee
(
    ssn         TEXT
            primary key,
    lastname    TEXT,
    firstname   TEXT,
    hiredate    TEXT,
    salary      TEXT,
    gender      TEXT,
    performance TEXT,
    positionID  INTEGER,
    locationID  INTEGER,
    foreign key (locationID) references location(locationID),
    foreign key (positionID) references position(positionID)
)

/* Answer the following: How many emplyees have a good job performance? good job performance refers to performance = 'Good' */
SELECT 
SELECT COUNT(*) FROM employee WHERE performance = 'Good'
/* Given the following database schema: */
CREATE TABLE location
(
    locationID   INTEGER
        constraint location_pk
            primary key,
    locationcity TEXT,
    address      TEXT,
    state        TEXT,
    zipcode      INTEGER,
    officephone  TEXT
)

CREATE TABLE position
(
    positionID        INTEGER
        constraint position_pk
            primary key,
    positiontitle     TEXT,
    educationrequired TEXT,
    minsalary         TEXT,
    maxsalary         TEXT
)

CREATE TABLE employee
(
    ssn         TEXT
            primary key,
    lastname    TEXT,
    firstname   TEXT,
    hiredate    TEXT,
    salary      TEXT,
    gender      TEXT,
    performance TEXT,
    positionID  INTEGER,
    locationID  INTEGER,
    foreign key (locationID) references location(locationID),
    foreign key (positionID) references position(positionID)
)

/* Answer the following: Please list the social security numbers of the male employees with a salary of over $70,000 a year. social security numbers refers to ssn; male employees refers to gender = 'M'; salary of over $70,000 a year refers to salary > '70000' */
SELECT 
SELECT ssn FROM employee WHERE gender = 'M' AND CAST(REPLACE(SUBSTR(salary, 4), ',', '') AS REAL) > 70000
/* Given the following database schema: */
CREATE TABLE location
(
    locationID   INTEGER
        constraint location_pk
            primary key,
    locationcity TEXT,
    address      TEXT,
    state        TEXT,
    zipcode      INTEGER,
    officephone  TEXT
)

CREATE TABLE position
(
    positionID        INTEGER
        constraint position_pk
            primary key,
    positiontitle     TEXT,
    educationrequired TEXT,
    minsalary         TEXT,
    maxsalary         TEXT
)

CREATE TABLE employee
(
    ssn         TEXT
            primary key,
    lastname    TEXT,
    firstname   TEXT,
    hiredate    TEXT,
    salary      TEXT,
    gender      TEXT,
    performance TEXT,
    positionID  INTEGER,
    locationID  INTEGER,
    foreign key (locationID) references location(locationID),
    foreign key (positionID) references position(positionID)
)

/* Answer the following: What is the required education for the position of regional manager? required education refers to educationrequired; position of regional manager refers to  positiontitle = 'Regional Manager' */
SELECT 
SELECT educationrequired FROM position WHERE positiontitle = 'Regional Manager'
/* Given the following database schema: */
CREATE TABLE location
(
    locationID   INTEGER
        constraint location_pk
            primary key,
    locationcity TEXT,
    address      TEXT,
    state        TEXT,
    zipcode      INTEGER,
    officephone  TEXT
)

CREATE TABLE position
(
    positionID        INTEGER
        constraint position_pk
            primary key,
    positiontitle     TEXT,
    educationrequired TEXT,
    minsalary         TEXT,
    maxsalary         TEXT
)

CREATE TABLE employee
(
    ssn         TEXT
            primary key,
    lastname    TEXT,
    firstname   TEXT,
    hiredate    TEXT,
    salary      TEXT,
    gender      TEXT,
    performance TEXT,
    positionID  INTEGER,
    locationID  INTEGER,
    foreign key (locationID) references location(locationID),
    foreign key (positionID) references position(positionID)
)

/* Answer the following: Which position has a lower minimum salary, Account Representative or Trainee? position of Account Representative refers to positiontitle = 'Account Representative'; position of Trainee refers to positiontitle = 'Trainee'; lower minimum salary refers to MIN(minsalary) */
SELECT 
SELECT positiontitle FROM position WHERE positiontitle = 'Account Representative' OR positiontitle = 'Trainee' ORDER BY minsalary ASC LIMIT 1
/* Given the following database schema: */
CREATE TABLE location
(
    locationID   INTEGER
        constraint location_pk
            primary key,
    locationcity TEXT,
    address      TEXT,
    state        TEXT,
    zipcode      INTEGER,
    officephone  TEXT
)

CREATE TABLE position
(
    positionID        INTEGER
        constraint position_pk
            primary key,
    positiontitle     TEXT,
    educationrequired TEXT,
    minsalary         TEXT,
    maxsalary         TEXT
)

CREATE TABLE employee
(
    ssn         TEXT
            primary key,
    lastname    TEXT,
    firstname   TEXT,
    hiredate    TEXT,
    salary      TEXT,
    gender      TEXT,
    performance TEXT,
    positionID  INTEGER,
    locationID  INTEGER,
    foreign key (locationID) references location(locationID),
    foreign key (positionID) references position(positionID)
)

/* Answer the following: In which city's office does Sandy Adams work at? Sandy Adams is the fullname of an employee; full name = firstname, lastname; city refers to locationcity */
SELECT 
SELECT T2.locationcity FROM employee AS T1 INNER JOIN location AS T2 ON T1.locationID = T2.locationID WHERE T1.lastname = 'Adams' AND T1.firstname = 'Sandy'