question
stringlengths
326
2.82k
answer
stringlengths
23
804
db_schema
stringclasses
67 values
db_name
stringclasses
67 values
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "English" is the name of language Question: How many films are in English?
SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T2.name = 'English'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: address location refers to address Question: Give the address location of Heather Morris.
SELECT T1.address FROM address AS T1 INNER JOIN customer AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = 'HEATHER' AND T2.last_name = 'MORRIS'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "1411 Lillydate Drive" is the address Question: Give the email address of the person who lives in "1411 Lillydale Drive".
SELECT T2.email FROM address AS T1 INNER JOIN staff AS T2 ON T1.address_id = T2.address_id WHERE T1.address = '1411 Lillydale Drive'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: customer no. 297 refers to customer_id = 297; at 12:27:27 on 2005/7/28 refers to rental_date = '2005-07-28 12:27:27'; money pay for rent refers to amount Question: How much money did the customer No.297 pay for the rental which happened at 12:27:27 on 2005/7/28?
SELECT T1.amount FROM payment AS T1 INNER JOIN rental AS T2 ON T1.rental_id = T2.rental_id WHERE T2.rental_date = '2005-07-28 12:27:27' AND T2.customer_id = 297
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "WORKING MICROCOSMOS" is the title of film; category refers to name Question: Which category does the film Working Microcosmos belong to?
SELECT T3.name FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T1.title = 'WORKING MICROCOSMOS'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "Documentary" is the name of category; number of film refers to Count(film_id) Question: Give the number of documentary films.
SELECT COUNT(T1.film_id) FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id WHERE T2.name = 'Documentary'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: category refers to name; most number of films refers to Max(Count(film_id)) Question: State the name of the category which has the most number of films.
SELECT T.name FROM ( SELECT T2.name, COUNT(T1.film_id) AS num FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T2.name ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: inventory no. 3479 refers to inventory_id = '3479'; name of film refers to title Question: Give the name of the film for inventory No.3479.
SELECT T1.title FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T2.inventory_id = 3479
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: store no. 1 refers to store_id = 1; store no.2 refers to store_id = 2; rental payment refers to amount; percent more = Divide (Subtract(amount where store_id = 2, amount where store_id = 1), amount where store_id = 1) *100 Question: What is the percentage more for the rental payment for store No.2 than store No.1?
SELECT CAST((SUM(IIF(T2.store_id = 2, T1.amount, 0)) - SUM(IIF(T2.store_id = 1, T1.amount, 0))) AS REAL) * 100 / SUM(IIF(T2.store_id = 1, T1.amount, 0)) FROM payment AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id INNER JOIN store AS T3 ON T2.store_id = T3.store_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: indian refers to country = 'India'; Italian refers to country = 'Italy'; times = Divide(Count(city where country = 'India), Count(city where country = 'Italy')) Question: How many times is the number of Indian cities than Italian cities?
SELECT CAST(SUM(IIF(T1.country = 'India', 1, 0)) AS REAL) / SUM(IIF(T1.country = 'Italy', 1, 0)) FROM country AS T1 INNER JOIN city AS T2 ON T1.country_id = T2.country_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "Gina DeGeneres" and "Penelope Guinness" are both full name of actor; times number of film = Divide (Count (film_id where first_name = 'GINA' and last_name = 'DEGENERES'), Count(film_id where first_name = 'PENELOPE' and last_name = 'GUINESS')) Question: How many times is the number of films Gina DeGeneres acted in than Penelope Guinness?
SELECT CAST(SUM(IIF(T2.first_name = 'GINA' AND T2.last_name = 'DEGENERES', 1, 0)) AS REAL) * 100 / SUM(IIF(T2.first_name = 'PENELOPE' AND T2.last_name = 'GUINESS', 1, 0)) FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: restricted refers to rating = 'R'; release refers to release_year; in 2006 refers to release_year = 2006; film refers to title Question: In 2006, how many restricted films were released?
SELECT COUNT(film_id) FROM film WHERE rating = 'R' AND release_year = 2006
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: Question: How many actors starred in the film id 508?
SELECT COUNT(actor_id) FROM film_actor WHERE film_id = 508
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "SMOOCHY CONTROL" is the title of film Question: What are the special features for the film "Smoochy Control"?
SELECT special_features FROM film WHERE title = 'SMOOCHY CONTROL'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: over the amount of 10 refers to amount > 10; paid on August 2005 refers to payment_date like '2005_08%'; customer refers to customer_id Question: How many customers paid over the amount of 10 on August 2005?
SELECT COUNT(customer_id) FROM payment WHERE SUBSTR(payment_date, 1, 7) LIKE '2005-08'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: more than 180 min long refers to length > 180; name of film refers to title Question: List the names of the films that are more than 180 minutes long.
SELECT title FROM film WHERE length > 180
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: first 10 rental refers to rental id between 1 and 10; total rental payment refers to sum(amount) Question: How much is the total rental payment for the first 10 rentals?
SELECT SUM(amount) FROM payment WHERE rental_id BETWEEN 1 AND 10
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: active employee refers to active = 1; full name refers to first_name, last_name Question: What are the full names of all the active employees?
SELECT first_name, last_name FROM staff WHERE active = 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: staff manager refers to manager_staff_id Question: Who is the staff manager in store id 2?
SELECT manager_staff_id FROM store WHERE store_id = 2
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: return on 5/27/2005 refers to return_date = '2005-05-27'; rental refers to rental_id Question: How many rentals were returned on 5/27/2005?
SELECT COUNT(rental_id) FROM rental WHERE rental_date = '2005-05-27'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: name of movie refers to title Question: What are the names of the movies which Laura Brody starred in?
SELECT T3.title FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'Laura' AND T1.last_name = 'Brody'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: name of film refers to title Question: List the name of the films that can only be found in store id 2.
SELECT T1.title FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T2.store_id = 2
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: rented for 7 consecutive days refers to Subtract(return_date, rental_date) = 7; full name refers to first_name, last_name Question: What is the full name of the customer who rented movies for 7 consecutive days?
SELECT T1.first_name, T1.last_name FROM customer AS T1 INNER JOIN ( SELECT customer_id, COUNT(*) AS num_days FROM ( SELECT *, date(days, '-' || rn || ' day') AS results FROM ( SELECT customer_id, days, row_number() OVER (PARTITION BY customer_id ORDER BY days) AS rn FROM ( SELECT DISTINCT customer_id, date(rental_date) AS days FROM rental ) ) ) GROUP BY customer_id, results HAVING num_days = 7 ) AS T2 ON T1.customer_id = T2.customer_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "Horror" is the name of category Question: How many films are categorized as horror?
SELECT COUNT(T1.film_id) FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id WHERE T2.name = 'Horror'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: most rented movie refers to title where Max(Count(rental_id)) Question: What is the name of the most rented movie?
SELECT T.title FROM ( SELECT T1.title, COUNT(T3.rental_id) AS num FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id INNER JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T1.title ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "science fiction" is the name of category; most common special features refers to Max(frequency(special_features)) Question: What is the most common special features of science-fiction movies?
SELECT T1.special_features FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T3.name = 'sci-fi' ORDER BY T1.special_features DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; actor who starred in the most movies refers to actor_id where Max(Count(film_id)) Question: What is the full name of the actor who starred in most movies?
SELECT T.first_name, T.last_name FROM ( SELECT T2.first_name, T2.last_name, COUNT(T1.film_id) AS num FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.first_name, T2.last_name ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: rental duration of 7 refers to rental_duration = 7; comedies refers to name = 'Comedy' Question: Among the films with a rental duration of 7 days, how many are comedies?
SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T1.rental_duration = 7 AND T3.name = 'Comedy'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: most non-active customer refers to Max(Count(active = 0)) Question: Who is the staff manager of the store with the most non-active customers?
SELECT T.first_name, T.last_name FROM ( SELECT T3.first_name, T3.last_name, COUNT(T1.customer_id) AS num FROM customer AS T1 INNER JOIN store AS T2 ON T1.store_id = T2.store_id INNER JOIN staff AS T3 ON T2.store_id = T3.store_id WHERE T1.active = 0 GROUP BY T3.first_name, T3.last_name ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: children's film refers to name = 'Children'; average price per day of most expensive film = Max(Divide(rental_rate, rental_duration)) Question: What is the rental price per day of the most expensive children's film?
SELECT T1.rental_rate FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T3.name = 'Children' ORDER BY T1.rental_rate / T1.rental_duration DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: complete address refers to address, address2, district Question: What is the complete address of store id 1?
SELECT T3.address, T3.address2, T3.district FROM country AS T1 INNER JOIN city AS T2 ON T1.country_id = T2.country_id INNER JOIN address AS T3 ON T2.city_id = T3.city_id INNER JOIN store AS T4 ON T3.address_id = T4.address_id WHERE T4.store_id = 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: customer refers to customer_id Question: How many customers are from the city of Lethbridge?
SELECT COUNT(T3.customer_id) FROM city AS T1 INNER JOIN address AS T2 ON T1.city_id = T2.city_id INNER JOIN customer AS T3 ON T2.address_id = T3.address_id WHERE T1.city = 'Lethbridge'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "United States" is the country Question: How many cities are there in the United States?
SELECT COUNT(T2.city) FROM country AS T1 INNER JOIN city AS T2 ON T1.country_id = T2.country_id WHERE T1.country = 'United States'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "India" is the country; name refers to first_name, last_name Question: List the names of the customers from India.
SELECT T4.first_name, T4.last_name FROM country AS T1 INNER JOIN city AS T2 ON T1.country_id = T2.country_id INNER JOIN address AS T3 ON T2.city_id = T3.city_id INNER JOIN customer AS T4 ON T3.address_id = T4.address_id WHERE T1.country = 'India'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: classic movie refers to name = 'Classics'; rental rate of less than 1 refers to rental_rate < 1; movie refers to film_id Question: Among the classic movies, how many movies have a rental rate of less than 1?
SELECT COUNT(T1.film_id) FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id WHERE T3.rental_rate < 1 AND T2.name = 'Classics'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; customer who rented the most film refers to Max(count(rental_id)) Question: What is the full name of the customer who rented the highest number of movies of all time?
SELECT T.first_name, T.last_name FROM ( SELECT T2.first_name, T2.last_name, COUNT(T1.rental_id) AS num FROM rental AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.first_name, T2.last_name ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "BLANKET BEVERLY" is the title of film; rented times refers to count(rental_id) Question: How many times was "Blanket Beverly" rented?
SELECT COUNT(T3.rental_id) FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id INNER JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id WHERE T1.title = 'Blanket Beverly'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: restricted refers to rating = 'R'; highest number of film refers to Max(Count(film_id)); full name refers to first_name, last_name Question: What is the full name of the actor who has the highest number of restricted films?
SELECT T.first_name, T.last_name FROM ( SELECT T1.first_name, T1.last_name, COUNT(T2.film_id) AS num FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.rating = 'R' GROUP BY T1.first_name, T1.last_name ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: actors with highest number of films refers to actor_id with Max(Count(film_id)); full name refers to first_name, last_name; average number of film = Divide (Count(film_id), 5) Question: Who are the top 5 actors with the highest number of films? List their full names and calculate the average number of films for each of the actors.
SELECT T.first_name, T.last_name, num FROM ( SELECT T1.first_name, T1.last_name, COUNT(T2.film_id) AS num FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id GROUP BY T1.first_name, T1.last_name ) AS T ORDER BY T.num DESC LIMIT 5
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: Question: List the actors' IDs who have "KILMER" as last name.
SELECT actor_id FROM actor WHERE last_name = 'KILMER'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: lowest replacement cost refers to Min(replacement_cost); under general audience rating refers to rating = G Question: List down the films titles with the lowest replacement cost under the general audiences rating.
SELECT title FROM film WHERE replacement_cost = ( SELECT MIN(replacement_cost) FROM film )
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: longest duration of film refers to Max(length) Question: Among the films with the longest duration, list any five title with their descriptions and special features.
SELECT title, description, special_features FROM film WHERE length = ( SELECT MAX(length) FROM film ) LIMIT 5
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: rented on 26th May 2005 refers to rental_date = '2005-05-26'; return on 30th May, 2005 refers to return_date = '2005-05-30'; number of rented film refers to Count (rental_id) Question: How many films rented on 26th May, 2005 were returned on 30th May, 2005?
SELECT COUNT(DISTINCT rental_id) FROM rental WHERE date(rental_date) BETWEEN '2005-05-26' AND '2005-05-30'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: average payment refers to AVG(amount) Question: Calculate the average payment amount per customer.
SELECT AVG(amount) FROM payment GROUP BY customer_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: name refers to first_name, last_name Question: What is the name and email of the staff in store ID 2?
SELECT first_name, last_name, email FROM staff WHERE store_id = 2
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: inactive refers to active = 0; percent = Divide (Count (customer_id where active = 0), Count(customer_id)) * 100 Question: How many percent of customers were inactive?
SELECT CAST(SUM(IIF(active = 0, 1, 0)) AS REAL) * 100 / COUNT(customer_id) FROM customer
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: ID 996 refers to film_id = 996 Question: What is the description and film title of ID 996?
SELECT description, title FROM film_text WHERE film_id = 996
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: in August 2005 refers to payment_date like '2005-08%'; total payment amount refers to Sum(amount) Question: Calculate customers' total payment amount in August, 2005.
SELECT SUM(amount) FROM payment WHERE SUBSTR(payment_date, 1, 7) = '2005-08'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: Question: List down the film titles performed by Emily Dee.
SELECT T3.title FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'Emily' AND T1.last_name = 'Dee'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "CHOCOLATE DUCK" is the title of film; full name refers to first_name, last_name Question: List down the actors' full names who performed in "CHOCOLATE DUCK" film.
SELECT T3.first_name, T3.last_name FROM film_actor AS T1 INNER JOIN film AS T2 ON T1.film_id = T2.film_id INNER JOIN actor AS T3 ON T1.actor_id = T3.actor_id WHERE T2.title = 'CHOCOLATE DUCK'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "Horror" is the name of category; PG-13 rated refers to rating = 'PG-13' Question: How many films in the horror category were included in PG-13-rated?
SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T3.name = 'Horror' AND T1.rating = 'PG-13'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: films performed refers to film Question: Distinguish the films performed by Judy Dean according to category.
SELECT T5.name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id INNER JOIN film_category AS T4 ON T2.film_id = T4.film_id INNER JOIN category AS T5 ON T4.category_id = T5.category_id WHERE T1.first_name = 'Judy' AND T1.last_name = 'Dean'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "Documentary" is the name of category; film name refers to title Question: Write down any five film names under the documentary category.
SELECT T1.title FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T3.name = 'Documentary' LIMIT 5
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "UNTOUCHABLES SUNRISE" is the title of film; language refers to name; rental cost per day = Divide (rental_cost, rental_duration) Question: Mention the language of Untouchables Sunrise film and calculate its rental cost per day.
SELECT T2.name, T1.replacement_cost / T1.rental_duration AS cost FROM film AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'UNTOUCHABLES SUNRISE'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: rented on 24th May 2005 refers to rental_date = '2005-05-24%' Question: List the films' titles which were rented on 24th May,2005.
SELECT T1.title FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id INNER JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id WHERE SUBSTR(T3.rental_date, 1, 10) = '2005-05-24'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: rented in July 2005 refers to year (rental_date) = 2005 and month (rental_date) = 7 Question: List the films' titles which were rented by Brian Wyman in July, 2005.
SELECT T4.title FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T1.first_name = 'BRIAN' AND T1.last_name = 'WYMAN' AND STRFTIME('%Y', T2.rental_date) = '2005' AND STRFTIME('%m',T2.rental_date) = '7'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: "STREETCAR INTENTIONS" is the title of film; actor's names refers to first_name, last_name Question: Write down the inventories' IDs and actors' names of "STREETCAR INTENTIONS".
SELECT T4.inventory_id, T1.first_name, T1.last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id INNER JOIN inventory AS T4 ON T2.film_id = T4.film_id WHERE T3.title = 'STREETCAR INTENTIONS'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: category refers to name; rented in February 2006 refers to year(rental_date) = 2006 and month (rental_rate) = 2 Question: Among the films rented by Natalie Meyer, describe the titles and categories of the films which were rented in February 2006.
SELECT T3.title, T2.name FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id INNER JOIN inventory AS T4 ON T3.film_id = T4.film_id INNER JOIN customer AS T5 ON T4.store_id = T5.store_id INNER JOIN rental AS T6 ON T4.inventory_id = T6.inventory_id WHERE T5.first_name = 'Natalie' AND T5.last_name = 'Meyer' AND STRFTIME('%Y',T3.rental_rate) = '2006' AND STRFTIME('%m',T3.rental_rate) = '2'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Eleanor Hunt' is the full name of a customer; full name refers to first_name, last_name Question: How many rental IDs belong to Eleanor Hunt?
SELECT COUNT(T1.rental_id) FROM rental AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'Eleanor' AND T2.last_name = 'Hunt'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; 'DREAM PICKUP' is a title of film Question: Describe the full names and cities of the customers who rented "DREAM PICKUP".
SELECT T4.first_name, T4.last_name, T6.city FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id INNER JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN customer AS T4 ON T3.customer_id = T4.customer_id INNER JOIN address AS T5 ON T4.address_id = T5.address_id INNER JOIN city AS T6 ON T5.city_id = T6.city_id WHERE T1.title = 'DREAM PICKUP'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'India' is a country; calculation = DIVIDE(SUM(country = 'India'), COUNT(customer_id)) * 100 Question: Calculate how many percent of customers were located in India.
SELECT CAST(SUM(IIF(T1.country = 'India', 1, 0)) AS REAL) * 100 / COUNT(T4.customer_id) FROM country AS T1 INNER JOIN city AS T2 ON T1.country_id = T2.country_id INNER JOIN address AS T3 ON T2.city_id = T3.city_id INNER JOIN customer AS T4 ON T3.address_id = T4.address_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Mary Keitel' AND 'Angela Witherspoon' are full name of actors; full name refers to FirstName, LastName; calculation = DIVIDE(SUBTRACT(SUM('Mary Keitel'), SUM('Angela Witherspoon')), SUM('Angela Witherspoon')) * 100 Question: How much percentage of the film did Mary Keitel perform more than Angela Witherspoon?
SELECT CAST((SUM(IIF(T1.first_name = 'ANGELA' AND T1.last_name = 'WITHERSPOON', 1, 0)) - SUM(IIF(T1.first_name = 'MARY' AND T1.last_name = 'KEITEL', 1, 0))) AS REAL) * 100 / SUM(IIF(T1.first_name = 'MARY' AND T1.last_name = 'KEITEL', 1, 0)) FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Lillie Kim' is the full name of a customer; full name refers to first_name, last_name Question: Provide the email, address, city, and country of the customer Lillie Kim.
SELECT T1.email, T2.address, T3.city, T4.country FROM customer AS T1 INNER JOIN address AS T2 ON T1.address_id = T2.address_id INNER JOIN city AS T3 ON T2.city_id = T3.city_id INNER JOIN country AS T4 ON T3.country_id = T4.country_id WHERE T1.first_name = 'Lillie' AND T1.last_name = 'Kim'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; 'Mike Hillyer' is a full name of a staff; Question: Provide any 5 customers' full names who have rented from Mike Hillyer.
SELECT T3.first_name, T3.last_name FROM staff AS T1 INNER JOIN address AS T2 ON T1.address_id = T2.address_id INNER JOIN customer AS T3 ON T2.address_id = T3.address_id WHERE T1.first_name = 'Mike' AND T1.last_name = 'Hillyer' LIMIT 5
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Diane Collins' is a full name of a customer; full name refers to first_name, last_name Question: Calculate the total payment amount by Diane Collins.
SELECT SUM(T2.amount) FROM customer AS T1 INNER JOIN payment AS T2 ON T1.customer_id = T2.customer_id WHERE T1.first_name = 'Diane' AND T1.last_name = 'Collins'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; average payment refers to AVG(amount); payments were greater than 70% of the average refers to amount > (AVG(amount) MULTIPLY 0.7) Question: Provide the full names and emails of customers whose payments were greater than 70% of the average.
SELECT DISTINCT T2.first_name, T2.last_name, T2.email FROM payment AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id INNER JOIN address AS T3 ON T2.address_id = T3.address_id WHERE T1.amount > ( SELECT AVG(amount) FROM payment ) * 0.7
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: Question: How many films have a rental rate of 0.99?
SELECT COUNT(film_id) FROM film WHERE rental_rate = 0.99
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: customer ID of 100 and below refers to customer_id < 100 Question: Among the customers with customer ID of 100 and below, how many of them have Thomas as their last name?
SELECT COUNT(customer_id) FROM customer WHERE last_name = 'Thomas' AND customer_id < 100
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: Question: List the actor's last name that starred the film with the description of "A Thoughtful Drama of a Composer And a Feminist who must Meet a Secret Agent in The Canadian Rockies".
SELECT T1.last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.description = 'A Thoughtful Drama of a Composer And a Feminist who must Meet a Secret Agent in The Canadian Rockies'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: Liza Bergman' is a full name; full name refers to first_name, last_name; highest replacement cost refers to MAX(replacement_cost) Question: Give the title of the film starred by Liza Bergman with the highest replacement cost.
SELECT T3.title FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'Liza' AND T1.last_name = 'Bergman' ORDER BY replacement_cost DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: highest rental rate refers to MAX(rental_rate) Question: Among films with store ID of 2, list the title of films with the highest rental rate.
SELECT T1.title FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T2.store_id = 2 ORDER BY rental_rate DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: Angelina Astaire' is a full name of an actor; full name refers to first_name, last_name Question: Among the films starred by Angelina Astaire, what is the title of the film with a replacement cost of 27.99?
SELECT T3.title FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'Angelina' AND T1.last_name = 'Astaire' AND T3.replacement_cost = 27.99
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'African Egg' is a title of a film Question: List the inventory ID of the film titled "African Egg".
SELECT T2.inventory_id FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T1.title = 'African Egg'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: length duration of 113 minutes refers to length = 113; 'Kirk Jovovich' is a full name of an actor; full name refers to first_name, last_name Question: In films with a length duration of 113 minutes, how many of the films are starred by Kirk Jovovich?
SELECT COUNT(T1.actor_id) FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.length = 113 AND T1.first_name = 'Kirk' AND T1.last_name = 'Jovovich'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: G rating refers to rating = 'G' Question: In the film with an inventory ID between 20 to 60, how many of the films have a G rating?
SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T2.inventory_id BETWEEN 20 AND 60 AND T1.rating = 'G'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: Bob Fawcett' is a full name of an actor; full name refers to first_name, last_name Question: Among films with a rental rate of 4.99, what is the total number of films starred by Bob Fawcett?
SELECT COUNT(T1.actor_id) FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.rental_rate = 4.99 AND T1.first_name = 'Bob' AND T1.last_name = 'Fawcett'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Russell Close' is a full name of an actor; full name refers to first_name, last_name; duration between 110 to 150 minutes refers to length BETWEEN 110 AND 150 Question: What is the inventory ID of the films starred by Russell Close with a duration between 110 to 150 minutes?
SELECT T4.inventory_id FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id INNER JOIN inventory AS T4 ON T3.film_id = T4.film_id WHERE T3.length BETWEEN 110 AND 150 AND T1.first_name = 'Russell' AND T1.last_name = 'Close'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: the longest duration refers to MAX(length) Question: What is the store and inventory ID of the film with the longest duration?
SELECT T2.store_id, T2.inventory_id FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id ORDER BY T1.length DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Elvis Marx' is a full name of a film; full name refers to first_name, last_name Question: List the titles of the films starred by Elvis Marx.
SELECT T3.title FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.length BETWEEN 110 AND 150 AND T1.first_name = 'Russell' AND T1.last_name = 'Close'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Lucille Dee' is a full name of an actor; full name refers to first_name, last_name Question: In films with rental rate of 4.99, list down the inventory ID of the films starred by Lucille Dee.
SELECT T4.inventory_id FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id INNER JOIN inventory AS T4 ON T3.film_id = T4.film_id WHERE T1.first_name = 'Lucille' AND T1.last_name = 'Dee' AND T3.rental_rate = 4.99
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: average rental rate of all listed films refers to AVG(rental_rate); rental rate greater than the 60% of average rental rate refers to rental_rate > (AVG(rental_rate)) MULTIPLY 0.6 Question: List the store ID of the films with a rental rate greater than the 60% of average rental rate of all listed films.
SELECT T2.store_id FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T1.rental_rate > ( SELECT AVG(T1.rental_rate) * 0.6 FROM film AS T1 )
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Nick Wahlberg' is a full name of an actor; full name refers to first_name, last_name; G rating refers to rating = 'G'; calculation = DIVIDE(SUM(rating = 'G'), SUM(rating)) * 100 Question: Among the films starred by Nick Wahlberg, what is the percentage of the films with G rating?
SELECT CAST(SUM(IIF(T3.rating = 'G', 1, 0)) AS REAL) / COUNT(T3.film_id) FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'Elvis' AND T1.last_name = 'Marx'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Texas' is a district Question: List the address in Texas in the ascending order of city id.
SELECT address FROM address WHERE district = 'Texas' AND city_id = ( SELECT MIN(city_id) FROM address WHERE district = 'Texas' )
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; record created in 2006 refers to create_date = 2006; inactive customers refers to active = 0 Question: Find the full name and email address of inactive customers whose record was created in 2006.
SELECT first_name, last_name, email FROM customer WHERE STRFTIME('%Y',create_date) = '2006' AND active = 0
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: PG-13 is a rating; calculation = DIVIDE(SUM(rating = PG-13), SUM(rating)) * 100 Question: What percentage of the movies are PG-13?
SELECT CAST(SUM(IIF(rating = 'PG-13', 1, 0)) AS REAL) * 100 / COUNT(film_id) FROM film
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: movies with the most price per day refers to MAX(rental_rate) Question: Please list the top ten movies with the most price per day in descending order of price per day.
SELECT title FROM film ORDER BY rental_rate / rental_duration DESC LIMIT 10
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: average rent amount refers to AVG(amount) Question: Calculate the average rent amount paid by the customer with customer id 15.
SELECT AVG(amount) FROM payment WHERE customer_id = 15
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: rented period refers to SUBTRACT(return_date, rental_date); calculation = rented period > (AVG(rented period)) Question: How many customers rented for an above-average period?
SELECT COUNT(customer_id) FROM rental WHERE return_date - rental_date > ( SELECT AVG(return_date - rental_date) FROM rental )
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: horror is a name of film category; calculation = DIVIDE(COUNT('horror'), COUNT(category_id)) * 100 Question: Among the movies, what percentage are horror?
SELECT CAST(SUM(IIF(T2.name = 'horror', 1, 0)) AS REAL) * 100 / COUNT(T2.category_id) FROM film_category AS T1 INNER JOIN category AS T2 ON T1.category_id = T2.category_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; acted in the most number of movies refers to MAX(COUNT(film_id)) Question: Give the full name of the actor who acted in the most number of movies?
SELECT T.first_name, T.last_name FROM ( SELECT T2.first_name, T2.last_name, COUNT(T1.film_id) AS num FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.first_name, T2.last_name ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; drama is a category of a film; acted the most in a movies refers to MAX(COUNT(film_id)) Question: Give the full name of the actor who acted the most in drama movies?
SELECT T.first_name, T.last_name FROM ( SELECT T1.first_name, T1.last_name, COUNT(T2.film_id) AS num FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film_category AS T3 ON T2.film_id = T3.film_id WHERE T3.category_id = 7 GROUP BY T1.first_name, T1.last_name ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Australia' AND 'Canada' are country; average number of films refers to AVG('Australia') AND AVG('Canada'); calculation = SUBTRACT(AVG('Australia'), AVG('Canada')) Question: What is the difference in the average number of films rented each day in Australia and Canada?
SELECT AVG(IIF(T4.country = 'Australia', 1, 0)) - AVG(IIF(T4.country = 'Canada', 1, 0)) AS diff FROM customer AS T1 INNER JOIN address AS T2 ON T1.address_id = T2.address_id INNER JOIN city AS T3 ON T2.city_id = T3.city_id INNER JOIN country AS T4 ON T3.country_id = T4.country_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Reese Kilmer' is a full name of an actor; 'action' is the name of the category; calculation = DIVIDE(COUNT('action'), COUNT(category_id)) * 100 Question: Of the movies in which Reese Kilmer acted, what percentage are action movies?
SELECT CAST(SUM(IIF(T4.name = 'Action', 1, 0)) AS REAL) * 100 / COUNT(T1.actor_id) FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film_category AS T3 ON T2.film_id = T3.film_id INNER JOIN category AS T4 ON T3.category_id = T4.category_id WHERE T1.first_name = 'Reese' AND T1.last_name = 'Kilmer'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Clockwork Paradice' is a title of a film Question: Give the total amount of rent for the movie Clockwork Paradice.
SELECT SUM(T1.amount) FROM payment AS T1 INNER JOIN rental AS T2 ON T1.rental_id = T2.rental_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id WHERE T4.title = 'CLOCKWORK PARADICE'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; types of movies means category of movies; rented more than five types of movies refers to COUNT(film_category) > 5 Question: Find and list the full name of customers who rented more than five types of movies.
SELECT T.first_name, T.last_name FROM ( SELECT T1.first_name, T1.last_name, COUNT(T1.customer_id) AS num FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id INNER JOIN film_category AS T5 ON T4.film_id = T5.film_id GROUP BY T1.first_name, T1.last_name ) AS T WHERE T.num > 5
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: comedy is the name of a category; average number of actors refers to AVG(actor_id) Question: What is the average number of actors acted in comedy movies?
SELECT AVG(T1.actor_id) FROM film_actor AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id INNER JOIN actor AS T4 ON T4.actor_id = T1.actor_id WHERE T3.name = 'comedy'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: children is the name of the category; rented the most refers to MAX(COUNT(title)) Question: In children's movies, which was rented the most?
SELECT T.title FROM ( SELECT T4.title, COUNT(T4.title) AS num FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film AS T4 ON T3.film_id = T4.film_id INNER JOIN film_category AS T5 ON T4.film_id = T5.film_id INNER JOIN category AS T6 ON T5.category_id = T6.category_id WHERE T6.name = 'Children' GROUP BY T4.title ) AS T ORDER BY T.num DESC LIMIT 1
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: store 1 refers to store_id = 1; average rent amount refers to AVG(amount); calculation = DIVIDE(amount > AVG(amount), COUNT(customer_id)) * 100 Question: Calculate the percentage of customers who paid more than the average rent amount in store 1.
SELECT CAST(( SELECT COUNT(T1.customer_id) FROM customer AS T1 INNER JOIN payment AS T2 ON T1.customer_id = T2.customer_id WHERE T2.amount > ( SELECT AVG(amount) FROM payment ) ) AS REAL) * 100 / ( SELECT COUNT(customer_id) FROM customer )
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: full name refers to first_name, last_name; 'family' AND 'Sci-Fi' are names of the category; customers who rented more family movies than Sci-Fi movies refers to count(name = 'Family') > count(name = 'Sci-Fi') Question: Find and list the full name of customers who rented more family movies than Sci-Fi movies.
SELECT DISTINCT IIF(SUM(IIF(T5.name = 'Family', 1, 0)) - SUM(IIF(T5.name = 'Sci-Fi', 1, 0)) > 0, T1.first_name, 0) FROM customer AS T1 INNER JOIN rental AS T2 ON T1.customer_id = T2.customer_id INNER JOIN inventory AS T3 ON T2.inventory_id = T3.inventory_id INNER JOIN film_category AS T4 ON T4.film_id = T3.film_id INNER JOIN category AS T5 ON T4.category_id = T5.category_id GROUP BY T1.customer_id
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3
Given the following database schema and relevant knowledge, use SQL to answer the question. Schema: Table actor, columns = [actor_id,first_name,last_name,last_update] Table address, columns = [address_id,address,address2,district,city_id,postal_code,phone,last_update] Table category, columns = [category_id,name,last_update] Table city, columns = [city_id,city,country_id,last_update] Table country, columns = [country_id,country,last_update] Table customer, columns = [customer_id,store_id,first_name,last_name,email,address_id,active,create_date,last_update] Table film, columns = [film_id,title,description,release_year,language_id,original_language_id,rental_duration,rental_rate,length,replacement_cost,rating,special_features,last_update] Table film_actor, columns = [actor_id,film_id,last_update] Table film_category, columns = [film_id,category_id,last_update] Table film_text, columns = [film_id,title,description] Table inventory, columns = [inventory_id,film_id,store_id,last_update] Table language, columns = [language_id,name,last_update] Table payment, columns = [payment_id,customer_id,staff_id,rental_id,amount,payment_date,last_update] Table rental, columns = [rental_id,rental_date,inventory_id,customer_id,return_date,staff_id,last_update] Table staff, columns = [staff_id,first_name,last_name,address_id,picture,email,store_id,active,username,password,last_update] Table store, columns = [*,store_id,manager_staff_id,address_id,last_update] Foreign_keys = [] Knowledge: 'Adults Only' refers to rating = 'NC-17' Question: Indicate the title of all the films rated as 'Adults Only'.
SELECT title FROM film WHERE rating = 'NC-17'
{'film_text': ['film_id', 'title', 'description'], 'actor': ['actor_id', 'first_name', 'last_name', 'last_update'], 'address': ['address_id', 'address', 'address2', 'district', 'city_id', 'postal_code', 'phone', 'last_update'], 'category': ['category_id', 'name', 'last_update'], 'city': ['city_id', 'city', 'country_id', 'last_update'], 'country': ['country_id', 'country', 'last_update'], 'customer': ['customer_id', 'store_id', 'first_name', 'last_name', 'email', 'address_id', 'active', 'create_date', 'last_update'], 'film': ['film_id', 'title', 'description', 'release_year', 'language_id', 'original_language_id', 'rental_duration', 'rental_rate', 'length', 'replacement_cost', 'rating', 'special_features', 'last_update'], 'film_actor': ['actor_id', 'film_id', 'last_update'], 'film_category': ['film_id', 'category_id', 'last_update'], 'inventory': ['inventory_id', 'film_id', 'store_id', 'last_update'], 'language': ['language_id', 'name', 'last_update'], 'payment': ['payment_id', 'customer_id', 'staff_id', 'rental_id', 'amount', 'payment_date', 'last_update'], 'rental': ['rental_id', 'rental_date', 'inventory_id', 'customer_id', 'return_date', 'staff_id', 'last_update'], 'staff': ['staff_id', 'first_name', 'last_name', 'address_id', 'picture', 'email', 'store_id', 'active', 'username', 'password', 'last_update'], 'store': ['store_id', 'manager_staff_id', 'address_id', 'last_update']}
movie_3