db_name
stringclasses
146 values
prompt
stringlengths
310
4.81k
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Retrieve the country that has published the most papers. # ### SQL: # # SELECT t1.country FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.country ORDER BY count(*) DESC LIMIT 1 # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Find the country that the most papers are affiliated with. # ### SQL: # # SELECT t1.country FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.country ORDER BY count(*) DESC LIMIT 1 # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Find the name of the organization that has published the largest number of papers. # ### SQL: # # SELECT t1.name FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.name ORDER BY count(*) DESC LIMIT 1 # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Which institution has the most papers? Find the name of the institution. # ### SQL: # # SELECT t1.name FROM inst AS t1 JOIN authorship AS t2 ON t1.instid = t2.instid JOIN papers AS t3 ON t2.paperid = t3.paperid GROUP BY t1.name ORDER BY count(*) DESC LIMIT 1 # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Find the titles of the papers that contain the word "ML". # ### SQL: # # SELECT title FROM papers WHERE title LIKE "%ML%" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Which papers have the substring "ML" in their titles? Return the titles of the papers. # ### SQL: # # SELECT title FROM papers WHERE title LIKE "%ML%" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Which paper's title contains the word "Database"? # ### SQL: # # SELECT title FROM papers WHERE title LIKE "%Database%" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Which papers have the substring "Database" in their titles? Show the titles of the papers. # ### SQL: # # SELECT title FROM papers WHERE title LIKE "%Database%" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Find the first names of all the authors who have written a paper with title containing the word "Functional". # ### SQL: # # SELECT t1.fname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title LIKE "%Functional%" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Who has written a paper that has the word "Functional" in its title? Return the first names of the authors. # ### SQL: # # SELECT t1.fname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title LIKE "%Functional%" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Find the last names of all the authors that have written a paper with title containing the word "Monadic". # ### SQL: # # SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title LIKE "%Monadic%" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Which authors have written a paper with title containing the word "Monadic"? Return their last names. # ### SQL: # # SELECT t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title LIKE "%Monadic%" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Retrieve the title of the paper that has the largest number of authors. # ### SQL: # # SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid = t2.paperid WHERE t1.authorder = (SELECT max(authorder) FROM authorship) # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Which paper has the most authors? Give me the paper title. # ### SQL: # # SELECT t2.title FROM authorship AS t1 JOIN papers AS t2 ON t1.paperid = t2.paperid WHERE t1.authorder = (SELECT max(authorder) FROM authorship) # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # What is the first name of the author with last name "Ueno"? # ### SQL: # # SELECT fname FROM authors WHERE lname = "Ueno" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Which authors have last name "Ueno"? List their first names. # ### SQL: # # SELECT fname FROM authors WHERE lname = "Ueno" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Find the last name of the author with first name "Amal". # ### SQL: # # SELECT lname FROM authors WHERE fname = "Amal" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Which authors have first name "Amal"? List their last names. # ### SQL: # # SELECT lname FROM authors WHERE fname = "Amal" # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Find the first names of all the authors ordered in alphabetical order. # ### SQL: # # SELECT fname FROM authors ORDER BY fname # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Sort the first names of all the authors in alphabetical order. # ### SQL: # # SELECT fname FROM authors ORDER BY fname # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Retrieve all the last names of authors in alphabetical order. # ### SQL: # # SELECT lname FROM authors ORDER BY lname # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Give me a list of all the last names of authors sorted in alphabetical order # ### SQL: # # SELECT lname FROM authors ORDER BY lname # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Retrieve all the first and last names of authors in the alphabetical order of last names. # ### SQL: # # SELECT fname , lname FROM authors ORDER BY lname # ### End.
icfp_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # Inst ( instID, name, country ) # Authors ( authID, lname, fname ) # Papers ( paperID, title ) # Authorship ( authID, instID, paperID, authOrder ) # # Authorship.paperID can be joined with Papers.paperID # Authorship.instID can be joined with Inst.instID # Authorship.authID can be joined with Authors.authID # ### Question: # # Sort the list of all the first and last names of authors in alphabetical order of the last names. # ### SQL: # # SELECT fname , lname FROM authors ORDER BY lname # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many different last names do the actors and actresses have? # ### SQL: # # SELECT count(DISTINCT last_name) FROM actor # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Count the number of different last names actors have. # ### SQL: # # SELECT count(DISTINCT last_name) FROM actor # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the most popular first name of the actors? # ### SQL: # # SELECT first_name FROM actor GROUP BY first_name ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the most common first name among all actors. # ### SQL: # # SELECT first_name FROM actor GROUP BY first_name ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the most popular full name of the actors? # ### SQL: # # SELECT first_name , last_name FROM actor GROUP BY first_name , last_name ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the most common full name among all actors. # ### SQL: # # SELECT first_name , last_name FROM actor GROUP BY first_name , last_name ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which districts have at least two addresses? # ### SQL: # # SELECT district FROM address GROUP BY district HAVING count(*) >= 2 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Give the districts which have two or more addresses. # ### SQL: # # SELECT district FROM address GROUP BY district HAVING count(*) >= 2 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the phone number and postal code of the address 1031 Daugavpils Parkway? # ### SQL: # # SELECT phone , postal_code FROM address WHERE address = '1031 Daugavpils Parkway' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Give the phone and postal code corresponding to the address '1031 Daugavpils Parkway'. # ### SQL: # # SELECT phone , postal_code FROM address WHERE address = '1031 Daugavpils Parkway' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which city has the most addresses? List the city name, number of addresses, and city id. # ### SQL: # # SELECT T2.city , count(*) , T1.city_id FROM address AS T1 JOIN city AS T2 ON T1.city_id = T2.city_id GROUP BY T1.city_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the city name, id, and number of addresses corresponding to the city with the most addressed? # ### SQL: # # SELECT T2.city , count(*) , T1.city_id FROM address AS T1 JOIN city AS T2 ON T1.city_id = T2.city_id GROUP BY T1.city_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many addresses are in the district of California? # ### SQL: # # SELECT count(*) FROM address WHERE district = 'California' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Count the number of addressed in the California district. # ### SQL: # # SELECT count(*) FROM address WHERE district = 'California' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which film is rented at a fee of 0.99 and has less than 3 in the inventory? List the film title and id. # ### SQL: # # SELECT title , film_id FROM film WHERE rental_rate = 0.99 INTERSECT SELECT T1.title , T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id HAVING count(*) < 3 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the title and id of the film which has a rental rate of 0.99 and an inventory of below 3? # ### SQL: # # SELECT title , film_id FROM film WHERE rental_rate = 0.99 INTERSECT SELECT T1.title , T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id HAVING count(*) < 3 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many cities are in Australia? # ### SQL: # # SELECT count(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id WHERE T2.country = 'Australia' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Count the number of cities in Australia. # ### SQL: # # SELECT count(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id WHERE T2.country = 'Australia' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which countries have at least 3 cities? # ### SQL: # # SELECT T2.country FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id GROUP BY T2.country_id HAVING count(*) >= 3 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the countries that contain 3 or more cities? # ### SQL: # # SELECT T2.country FROM city AS T1 JOIN country AS T2 ON T1.country_id = T2.country_id GROUP BY T2.country_id HAVING count(*) >= 3 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Find all the payment dates for the payments with an amount larger than 10 and the payments handled by a staff person with the first name Elsa. # ### SQL: # # SELECT payment_date FROM payment WHERE amount > 10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Elsa' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the payment dates for any payments that have an amount greater than 10 or were handled by a staff member with the first name Elsa? # ### SQL: # # SELECT payment_date FROM payment WHERE amount > 10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Elsa' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many customers have an active value of 1? # ### SQL: # # SELECT count(*) FROM customer WHERE active = '1' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Count the number of customers who are active. # ### SQL: # # SELECT count(*) FROM customer WHERE active = '1' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which film has the highest rental rate? And what is the rate? # ### SQL: # # SELECT title , rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the title and rental rate of the film with the highest rental rate? # ### SQL: # # SELECT title , rental_rate FROM film ORDER BY rental_rate DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which film has the most number of actors or actresses? List the film name, film id and description. # ### SQL: # # SELECT T2.title , T2.film_id , T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.film_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the title, id, and description of the movie with the greatest number of actors? # ### SQL: # # SELECT T2.title , T2.film_id , T2.description FROM film_actor AS T1 JOIN film AS T2 ON T1.film_id = T2.film_id GROUP BY T2.film_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which film actor (actress) starred the most films? List his or her first name, last name and actor id. # ### SQL: # # SELECT T2.first_name , T2.last_name , T2.actor_id FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the full name and id of the actor or actress who starred in the greatest number of films. # ### SQL: # # SELECT T2.first_name , T2.last_name , T2.actor_id FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which film actors (actresses) played a role in more than 30 films? List his or her first name and last name. # ### SQL: # # SELECT T2.first_name , T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id HAVING count(*) > 30 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the full names of actors who had roles in more than 30 films? # ### SQL: # # SELECT T2.first_name , T2.last_name FROM film_actor AS T1 JOIN actor AS T2 ON T1.actor_id = T2.actor_id GROUP BY T2.actor_id HAVING count(*) > 30 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which store owns most items? # ### SQL: # # SELECT store_id FROM inventory GROUP BY store_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the id of the store that has the most items in inventory? # ### SQL: # # SELECT store_id FROM inventory GROUP BY store_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the total amount of all payments? # ### SQL: # # SELECT sum(amount) FROM payment # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the sum of all payment amounts. # ### SQL: # # SELECT sum(amount) FROM payment # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which customer, who has made at least one payment, has spent the least money? List his or her first name, last name, and the id. # ### SQL: # # SELECT T1.first_name , T1.last_name , T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY sum(amount) ASC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the full name and id of the customer who has the lowest total amount of payment? # ### SQL: # # SELECT T1.first_name , T1.last_name , T1.customer_id FROM customer AS T1 JOIN payment AS T2 ON T1.customer_id = T2.customer_id GROUP BY T1.customer_id ORDER BY sum(amount) ASC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the genre name of the film HUNGER ROOF? # ### SQL: # # SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id = T2.category_id JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.title = 'HUNGER ROOF' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the name of the category to which the film 'HUNGER ROOF' belongs. # ### SQL: # # SELECT T1.name FROM category AS T1 JOIN film_category AS T2 ON T1.category_id = T2.category_id JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.title = 'HUNGER ROOF' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many films are there in each category? List the genre name, genre id and the count. # ### SQL: # # SELECT T2.name , T1.category_id , count(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T1.category_id # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the names and ids of the different categories, and how many films are in each? # ### SQL: # # SELECT T2.name , T1.category_id , count(*) FROM film_category AS T1 JOIN category AS T2 ON T1.category_id = T2.category_id GROUP BY T1.category_id # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which film has the most copies in the inventory? List both title and id. # ### SQL: # # SELECT T1.title , T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the title and id of the film that has the greatest number of copies in inventory? # ### SQL: # # SELECT T1.title , T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the film title and inventory id of the item in the inventory which was rented most frequently? # ### SQL: # # SELECT T1.title , T2.inventory_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T2.inventory_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the title and inventory id of the film that is rented most often. # ### SQL: # # SELECT T1.title , T2.inventory_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id JOIN rental AS T3 ON T2.inventory_id = T3.inventory_id GROUP BY T2.inventory_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many languages are in these films? # ### SQL: # # SELECT count(DISTINCT language_id) FROM film # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Count the number of different languages in these films. # ### SQL: # # SELECT count(DISTINCT language_id) FROM film # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are all the movies rated as R? List the titles. # ### SQL: # # SELECT title FROM film WHERE rating = 'R' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the titles of any movies with an R rating. # ### SQL: # # SELECT title FROM film WHERE rating = 'R' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Where is store 1 located? # ### SQL: # # SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE store_id = 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the address of store 1. # ### SQL: # # SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE store_id = 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which staff handled least number of payments? List the full name and the id. # ### SQL: # # SELECT T1.first_name , T1.last_name , T1.staff_id FROM staff AS T1 JOIN payment AS T2 ON T1.staff_id = T2.staff_id GROUP BY T1.staff_id ORDER BY count(*) ASC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Give the full name and staff id of the staff who has handled the fewest payments. # ### SQL: # # SELECT T1.first_name , T1.last_name , T1.staff_id FROM staff AS T1 JOIN payment AS T2 ON T1.staff_id = T2.staff_id GROUP BY T1.staff_id ORDER BY count(*) ASC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which language does the film AIRPORT POLLOCK use? List the language name. # ### SQL: # # SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'AIRPORT POLLOCK' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the name of the language that the film 'AIRPORT POLLOCK' is in? # ### SQL: # # SELECT T2.name FROM film AS T1 JOIN LANGUAGE AS T2 ON T1.language_id = T2.language_id WHERE T1.title = 'AIRPORT POLLOCK' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many stores are there? # ### SQL: # # SELECT count(*) FROM store # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Count the number of stores. # ### SQL: # # SELECT count(*) FROM store # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many kinds of different ratings are listed? # ### SQL: # # SELECT count(DISTINCT rating) FROM film # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Count the number of different film ratings. # ### SQL: # # SELECT count(DISTINCT rating) FROM film # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which movies have 'Deleted Scenes' as a substring in the special feature? # ### SQL: # # SELECT title FROM film WHERE special_features LIKE '%Deleted Scenes%' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the titles of films that include 'Deleted Scenes' in their special feature section. # ### SQL: # # SELECT title FROM film WHERE special_features LIKE '%Deleted Scenes%' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # How many items in inventory does store 1 have? # ### SQL: # # SELECT count(*) FROM inventory WHERE store_id = 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Count the number of items store 1 has in stock. # ### SQL: # # SELECT count(*) FROM inventory WHERE store_id = 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # When did the first payment happen? # ### SQL: # # SELECT payment_date FROM payment ORDER BY payment_date ASC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What was the date of the earliest payment? # ### SQL: # # SELECT payment_date FROM payment ORDER BY payment_date ASC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Where does the customer with the first name Linda live? And what is her email? # ### SQL: # # SELECT T2.address , T1.email FROM customer AS T1 JOIN address AS T2 ON T2.address_id = T1.address_id WHERE T1.first_name = 'LINDA' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the address and email of the customer with the first name Linda. # ### SQL: # # SELECT T2.address , T1.email FROM customer AS T1 JOIN address AS T2 ON T2.address_id = T1.address_id WHERE T1.first_name = 'LINDA' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Find all the films longer than 100 minutes, or rated PG, except those who cost more than 200 for replacement. List the titles. # ### SQL: # # SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' EXCEPT SELECT title FROM film WHERE replacement_cost > 200 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What are the titles of films that are either longer than 100 minutes or rated PG other than those that cost more than 200 to replace? # ### SQL: # # SELECT title FROM film WHERE LENGTH > 100 OR rating = 'PG' EXCEPT SELECT title FROM film WHERE replacement_cost > 200 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the first name and the last name of the customer who made the earliest rental? # ### SQL: # # SELECT T1.first_name , T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id = T2.customer_id ORDER BY T2.rental_date ASC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the full name of the customer who made the first rental. # ### SQL: # # SELECT T1.first_name , T1.last_name FROM customer AS T1 JOIN rental AS T2 ON T1.customer_id = T2.customer_id ORDER BY T2.rental_date ASC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # What is the full name of the staff member who has rented a film to a customer with the first name April and the last name Burns? # ### SQL: # # SELECT DISTINCT T1.first_name , T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id = T2.staff_id JOIN customer AS T3 ON T2.customer_id = T3.customer_id WHERE T3.first_name = 'APRIL' AND T3.last_name = 'BURNS' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the full name of the staff who provided a customer with the first name April and the last name Burns with a film rental. # ### SQL: # # SELECT DISTINCT T1.first_name , T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id = T2.staff_id JOIN customer AS T3 ON T2.customer_id = T3.customer_id WHERE T3.first_name = 'APRIL' AND T3.last_name = 'BURNS' # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Which store has most the customers? # ### SQL: # # SELECT store_id FROM customer GROUP BY store_id ORDER BY count(*) DESC LIMIT 1 # ### End.
sakila_1
### Complete SQL query only and with no explanation ### SQL tables followed by foreign key information: # # 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 ) # film_text ( film_id, title, description ) # 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 ) # # address.city_id can be joined with city.city_id # city.country_id can be joined with country.country_id # customer.store_id can be joined with store.store_id # customer.address_id can be joined with address.address_id # film.original_language_id can be joined with language.language_id # film.language_id can be joined with language.language_id # film_actor.film_id can be joined with film.film_id # film_actor.actor_id can be joined with actor.actor_id # film_category.category_id can be joined with category.category_id # film_category.film_id can be joined with film.film_id # inventory.film_id can be joined with film.film_id # inventory.store_id can be joined with store.store_id # payment.staff_id can be joined with staff.staff_id # payment.customer_id can be joined with customer.customer_id # payment.rental_id can be joined with rental.rental_id # rental.customer_id can be joined with customer.customer_id # rental.inventory_id can be joined with inventory.inventory_id # rental.staff_id can be joined with staff.staff_id # staff.address_id can be joined with address.address_id # store.address_id can be joined with address.address_id # store.manager_staff_id can be joined with staff.staff_id # ### Question: # # Return the id of the store with the most customers. # ### SQL: # # SELECT store_id FROM customer GROUP BY store_id ORDER BY count(*) DESC LIMIT 1 # ### End.