CREATE TABLE actor (
    actor_id NUMBER PRIMARY KEY,
    first_name TEXT,
    last_name TEXT,
    last_update TIME
);
CREATE TABLE address (
    address_id NUMBER PRIMARY KEY,
    address TEXT,
    address2 TEXT,
    district TEXT,
    city_id NUMBER,
    postal_code TEXT,
    phone TEXT,
    last_update TIME,
    FOREIGN KEY ("city_id") REFERENCES city("city_id")
);
CREATE TABLE category (
    category_id NUMBER PRIMARY KEY,
    name TEXT,
    last_update TIME
);
CREATE TABLE city (
    city_id NUMBER PRIMARY KEY,
    city TEXT,
    country_id NUMBER,
    last_update TIME,
    FOREIGN KEY ("country_id") REFERENCES country("country_id")
);
CREATE TABLE country (
    country_id NUMBER PRIMARY KEY,
    country TEXT,
    last_update TIME
);
CREATE TABLE customer (
    customer_id NUMBER PRIMARY KEY,
    store_id NUMBER,
    first_name TEXT,
    last_name TEXT,
    email TEXT,
    address_id NUMBER,
    active BOOLEAN,
    create_date TIME,
    last_update TIME,
    FOREIGN KEY ("store_id") REFERENCES store("store_id"),
    FOREIGN KEY ("address_id") REFERENCES address("address_id")
);
CREATE TABLE film (
    film_id NUMBER PRIMARY KEY,
    title TEXT,
    description TEXT,
    release_year TIME,
    language_id NUMBER,
    original_language_id NUMBER,
    rental_duration NUMBER,
    rental_rate NUMBER,
    length NUMBER,
    replacement_cost NUMBER,
    rating TEXT,
    special_features TEXT,
    last_update TIME,
    FOREIGN KEY ("original_language_id") REFERENCES language("language_id"),
    FOREIGN KEY ("language_id") REFERENCES language("language_id")
);
CREATE TABLE film_actor (
    actor_id NUMBER PRIMARY KEY,
    film_id NUMBER,
    last_update TIME,
    FOREIGN KEY ("film_id") REFERENCES film("film_id"),
    FOREIGN KEY ("actor_id") REFERENCES actor("actor_id")
);
CREATE TABLE film_category (
    film_id NUMBER PRIMARY KEY,
    category_id NUMBER,
    last_update TIME,
    FOREIGN KEY ("category_id") REFERENCES category("category_id"),
    FOREIGN KEY ("film_id") REFERENCES film("film_id")
);
CREATE TABLE film_text (
    film_id NUMBER PRIMARY KEY,
    title TEXT,
    description TEXT
);
CREATE TABLE inventory (
    inventory_id NUMBER PRIMARY KEY,
    film_id NUMBER,
    store_id NUMBER,
    last_update TIME,
    FOREIGN KEY ("film_id") REFERENCES film("film_id"),
    FOREIGN KEY ("store_id") REFERENCES store("store_id")
);
CREATE TABLE language (
    language_id NUMBER PRIMARY KEY,
    name TEXT,
    last_update TIME
);
CREATE TABLE payment (
    payment_id NUMBER PRIMARY KEY,
    customer_id NUMBER,
    staff_id NUMBER,
    rental_id NUMBER,
    amount NUMBER,
    payment_date TIME,
    last_update TIME,
    FOREIGN KEY ("staff_id") REFERENCES staff("staff_id"),
    FOREIGN KEY ("customer_id") REFERENCES customer("customer_id"),
    FOREIGN KEY ("rental_id") REFERENCES rental("rental_id")
);
CREATE TABLE rental (
    rental_id NUMBER PRIMARY KEY,
    rental_date TIME,
    inventory_id NUMBER,
    customer_id NUMBER,
    return_date TIME,
    staff_id NUMBER,
    last_update TIME,
    FOREIGN KEY ("customer_id") REFERENCES customer("customer_id"),
    FOREIGN KEY ("inventory_id") REFERENCES inventory("inventory_id"),
    FOREIGN KEY ("staff_id") REFERENCES staff("staff_id")
);
CREATE TABLE staff (
    staff_id NUMBER PRIMARY KEY,
    first_name TEXT,
    last_name TEXT,
    address_id NUMBER,
    picture OTHERS,
    email TEXT,
    store_id NUMBER,
    active BOOLEAN,
    username TEXT,
    password TEXT,
    last_update TIME,
    FOREIGN KEY ("address_id") REFERENCES address("address_id")
);
CREATE TABLE store (
    store_id NUMBER PRIMARY KEY,
    manager_staff_id NUMBER,
    address_id NUMBER,
    last_update TIME,
    FOREIGN KEY ("address_id") REFERENCES address("address_id"),
    FOREIGN KEY ("manager_staff_id") REFERENCES staff("staff_id")
);

Question: What are the payment dates for any payments that have an amount greater than 10 or were handled by a staff member with the first name Elsa?
SQL: SELECT payment_date FROM payment WHERE amount  >  10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.first_name  =  'Elsa'

Question: How many customers have an active value of 1?
SQL: SELECT count(*) FROM customer WHERE active = '1'

Question: Count the number of customers who are active.
SQL: SELECT count(*) FROM customer WHERE active = '1'

Question: Which film has the highest rental rate? And what is the rate?
SQL: SELECT title ,  rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1

Question: What are the title and rental rate of the film with the highest rental rate?
SQL: SELECT title ,  rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1

Question: Which film has the most number of actors or actresses? List the film name, film id and description.
SQL: SELECT T2.title ,  T2.film_id ,  T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id  =  T2.film_id GROUP BY T2.film_id ORDER BY count(*) DESC LIMIT 1

Question: What are the title, id, and description of the movie with the greatest number of actors?
SQL: SELECT T2.title ,  T2.film_id ,  T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id  =  T2.film_id GROUP BY T2.film_id ORDER BY count(*) DESC LIMIT 1

Question: Which film actor (actress) starred the most films? List his or her first name, last name and actor id.
SQL: SELECT T2.first_name ,  T2.last_name ,  T2.actor_id FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id  =  T2.actor_id GROUP BY T2.actor_id ORDER BY count(*) DESC LIMIT 1

Question: Return the full name and id of the actor or actress who starred in the greatest number of films.
SQL: SELECT T2.first_name ,  T2.last_name ,  T2.actor_id FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id  =  T2.actor_id GROUP BY T2.actor_id ORDER BY count(*) DESC LIMIT 1

Question: Which film actors (actresses) played a role in more than 30 films? List his or her first name and last name.
SQL: SELECT T2.first_name ,  T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id  =  T2.actor_id GROUP BY T2.actor_id HAVING count(*)  >  30

Question: What are the full names of actors who had roles in more than 30 films?
SQL: SELECT T2.first_name ,  T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id  =  T2.actor_id GROUP BY T2.actor_id HAVING count(*)  >  30

Question: Which store owns most items?
SQL: SELECT store_id FROM inventory GROUP BY store_id ORDER BY count(*) DESC LIMIT 1

Question: What is the id of the store that has the most items in inventory?
SQL: SELECT store_id FROM inventory GROUP BY store_id ORDER BY count(*) DESC LIMIT 1

Question: What is the total amount of all payments?
SQL: SELECT sum(amount) FROM payment

Question: Return the sum of all payment amounts.
SQL: SELECT sum(amount) FROM payment

Question: Which customer, who has made at least one payment, has spent the least money? List his or her first name, last name, and the id.
SQL: SELECT T1.first_name ,  T1.last_name ,  T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY sum(amount) ASC LIMIT 1

Question: What is the full name and id of the customer who has the lowest total amount of payment?
SQL: SELECT T1.first_name ,  T1.last_name ,  T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id ORDER BY sum(amount) ASC LIMIT 1

Question: What is the genre name of the film HUNGER ROOF?
SQL: SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id  =  T2.category_id JOIN film AS T3 ON T2.film_id  =  T3.film_id WHERE T3.title  =  'HUNGER ROOF'

Question: Return the name of the category to which the film 'HUNGER ROOF' belongs.
SQL: SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id  =  T2.category_id JOIN film AS T3 ON T2.film_id  =  T3.film_id WHERE T3.title  =  'HUNGER ROOF'