Database: sakila_1

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

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

Question: Which districts have at least two addresses?
SQL: SELECT district FROM address GROUP BY district HAVING count(*)  >=  2

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

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

Question: How many cities are there in Australia?
SQL: SELECT count(*) FROM city AS T1 JOIN country AS T2 ON T1.country_id  =  T2.country_id WHERE T2.country  =  'Australia'

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

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'

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

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

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

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

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