input
stringlengths
236
16.9k
output
stringlengths
19
805
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- List at least 10 films that falls into the Horror category.
SELECT T1.title FROM film AS T1 INNER JOIN film_category AS T2 ON T1.film_id = T2.film_id INNER JOIN category AS T3 ON T2.category_id = T3.category_id WHERE T3.name = 'Horror';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Who among the actors starred in a NC-17 rated film? Provide only the last name of the actors.
SELECT T1.last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T3.rating = 'NC-17';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Calculate the average rate of renting the film that Lucille Tracy got starred.
SELECT AVG(T3.rental_rate) FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'LUCILLE' AND T1.last_name = 'TRACY';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- How many films have a duration between 100 to 110 minutes?
SELECT COUNT(film_id) FROM film WHERE length BETWEEN 100 AND 110;
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- List down the actor ID of actors with Dee as their last name.
SELECT actor_id FROM actor WHERE last_name = 'Dee';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Among the active customers, how many of them have Nina as their first name?
SELECT COUNT(customer_id) FROM customer WHERE first_name = 'Nina' AND active = 1;
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- In store ID 2, how many of the films are R rating?
SELECT COUNT(T1.film_id) FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T2.store_id = 2 AND T1.rating = 'R';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- List the store ID of the films starred by Reese West with a duration of 100 minutes and below?
SELECT T4.store_id FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id INNER JOIN inventory AS T4 ON T3.film_id = T4.film_id WHERE T3.length < 100 AND T1.first_name = 'Reese' AND T1.last_name = 'West';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Give the duration of the film starred by Nick Wahlberg with the highest rental rate.
SELECT T3.title FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T2.film_id = T3.film_id WHERE T1.first_name = 'Nick' AND T1.last_name = 'Wahlberg' ORDER BY T3.rental_rate DESC LIMIT 1;
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- What are the titles of the films starred by Russell Close?
SELECT T3.title FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id WHERE T2.first_name = 'Russell' AND T2.last_name = 'Close';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- List the store ID of the film titled "Amadeus Holy".
SELECT T2.store_id FROM film AS T1 INNER JOIN inventory AS T2 ON T1.film_id = T2.film_id WHERE T1.title = 'Amadeus Holy';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- In films with a rental rate of 2.99, how many of the films are starred by Nina Soto?
SELECT COUNT(T1.film_id) FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id WHERE T3.rental_rate = 2.99 AND T2.first_name = 'Nina' AND T2.last_name = 'Soto';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Among the films starred by Reese West, what is the difference between the films that have store ID of 1 and store ID of 2?
SELECT SUM(IIF(T4.film_id = 1, 1, 0)) - SUM(IIF(T4.film_id = 2, 1, 0)) AS diff FROM film_actor AS T1 INNER JOIN actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T1.film_id = T3.film_id INNER JOIN inventory AS T4 ON T3.film_id = T4.film_id WHERE T2.first_name = 'Reese' AND T2.last_name = 'West';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- What is the postal code of the address 692 Joliet Street?
SELECT postal_code FROM address WHERE address = '692 Joliet Street';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- How many customers are active?
SELECT COUNT(customer_id) FROM customer WHERE active = 1;
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Among all the customers of store no.1, how many of them are active?
SELECT COUNT(customer_id) FROM customer WHERE active = 1 AND store_id = 1;
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- What is the address of Mary Smith?
SELECT T1.address FROM address AS T1 INNER JOIN customer AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = 'MARY' AND T2.last_name = 'SMITH';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Among all the active customers, how many of them live in Arlington?
SELECT COUNT(T2.customer_id) FROM address AS T1 INNER JOIN customer AS T2 ON T1.address_id = T2.address_id INNER JOIN city AS T3 ON T1.city_id = T3.city_id WHERE T2.active = 1 AND T3.city = 'Arlington';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Please list the full names of all the customers who live in Italy.
SELECT T4.first_name, T4.last_name FROM address AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id INNER JOIN country AS T3 ON T2.country_id = T3.country_id INNER JOIN customer AS T4 ON T1.address_id = T4.address_id WHERE T3.country = 'Italy';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Which country does Mary Smith live in?
SELECT T3.country FROM address AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id INNER JOIN country AS T3 ON T2.country_id = T3.country_id INNER JOIN customer AS T4 ON T1.address_id = T4.address_id WHERE T4.first_name = 'MARY' AND T4.last_name = 'SMITH';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- What is the biggest amount of payment for a rental made by Mary Smith?
SELECT T1.amount FROM payment AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'MARY' AND T2.last_name = 'SMITH' ORDER BY T1.amount DESC LIMIT 1;
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- How many times has Mary Smith rented a film?
SELECT COUNT(T1.customer_id) FROM payment AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'MARY' AND T2.last_name = 'SMITH';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- What is the total amount of money Mary Smith has spent on film rentals?
SELECT SUM(T1.amount) FROM payment AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'MARY' AND T2.last_name = 'SMITH';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Among the times Mary Smith had rented a movie, how many of them happened in June, 2005?
SELECT COUNT(T1.customer_id) FROM payment AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'MARY' AND T2.last_name = 'SMITH' AND STRFTIME('%Y',T1.payment_date) = '2005' AND STRFTIME('%Y', T1.payment_date) = '6';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Please give the full name of the customer who had made the biggest amount of payment in one single film rental.
SELECT T2.first_name, T2.last_name FROM payment AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id ORDER BY T1.amount DESC LIMIT 1;
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- How much in total had the customers in Italy spent on film rentals?
SELECT SUM(T5.amount) FROM address AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id INNER JOIN country AS T3 ON T2.country_id = T3.country_id INNER JOIN customer AS T4 ON T1.address_id = T4.address_id INNER JOIN payment AS T5 ON T4.customer_id = T5.customer_id WHERE T3.country = 'Italy';
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- Among the payments made by Mary Smith, how many of them are over 4.99?
SELECT COUNT(T1.amount) FROM payment AS T1 INNER JOIN customer AS T2 ON T1.customer_id = T2.customer_id WHERE T2.first_name = 'MARY' AND T2.last_name = 'SMITH' AND T1.amount > 4.99;
-- Database schema | film_text : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] | actor : actor_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , last_update [ DATETIME ] | address : address_id [ INTEGER ] primary_key , address [ TEXT ] , address2 [ TEXT ] , district [ TEXT ] , city_id [ INTEGER ] , postal_code [ TEXT ] , phone [ TEXT ] , last_update [ DATETIME ] | category : category_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | city : city_id [ INTEGER ] primary_key , city [ TEXT ] , country_id [ INTEGER ] , last_update [ DATETIME ] | country : country_id [ INTEGER ] primary_key , country [ TEXT ] , last_update [ DATETIME ] | customer : customer_id [ INTEGER ] primary_key , store_id [ INTEGER ] , first_name [ TEXT ] , last_name [ TEXT ] , email [ TEXT ] , address_id [ INTEGER ] , active [ INTEGER ] , create_date [ DATETIME ] , last_update [ DATETIME ] | film : film_id [ INTEGER ] primary_key , title [ TEXT ] , description [ TEXT ] , release_year [ TEXT ] , language_id [ INTEGER ] , original_language_id [ INTEGER ] , rental_duration [ INTEGER ] , rental_rate [ REAL ] , length [ INTEGER ] , replacement_cost [ REAL ] , rating [ TEXT ] , special_features [ TEXT ] , last_update [ DATETIME ] | film_actor : actor_id [ INTEGER ] , film_id [ INTEGER ] , last_update [ DATETIME ] | film_category : film_id [ INTEGER ] , category_id [ INTEGER ] , last_update [ DATETIME ] | inventory : inventory_id [ INTEGER ] primary_key , film_id [ INTEGER ] , store_id [ INTEGER ] , last_update [ DATETIME ] | language : language_id [ INTEGER ] primary_key , name [ TEXT ] , last_update [ DATETIME ] | payment : payment_id [ INTEGER ] primary_key , customer_id [ INTEGER ] , staff_id [ INTEGER ] , rental_id [ INTEGER ] , amount [ REAL ] , payment_date [ DATETIME ] , last_update [ DATETIME ] | rental : rental_id [ INTEGER ] primary_key , rental_date [ DATETIME ] , inventory_id [ INTEGER ] , customer_id [ INTEGER ] , return_date [ DATETIME ] , staff_id [ INTEGER ] , last_update [ DATETIME ] | staff : staff_id [ INTEGER ] primary_key , first_name [ TEXT ] , last_name [ TEXT ] , address_id [ INTEGER ] , picture [ BLOB ] , email [ TEXT ] , store_id [ INTEGER ] , active [ INTEGER ] , username [ TEXT ] , password [ TEXT ] , last_update [ DATETIME ] | store : store_id [ INTEGER ] primary_key , manager_staff_id [ INTEGER ] , address_id [ INTEGER ] , last_update [ DATETIME ] | -- -- What is the average amount of money spent by a customer in Italy on a single film rental?
SELECT AVG(T5.amount) FROM address AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id INNER JOIN country AS T3 ON T2.country_id = T3.country_id INNER JOIN customer AS T4 ON T1.address_id = T4.address_id INNER JOIN payment AS T5 ON T4.customer_id = T5.customer_id WHERE T3.country = 'Italy';