Try a query

Sample queries

Start with a question about the data, then adapt the SQL for your own database engine.

Sakila

Films by category

List the catalogue's films and their categories.

SELECT film_list.title, film_list.category, film_list.price FROM film_list ORDER BY film_list.category, film_list.title;
Get the database →

Sakila

Customer rentals

Show the latest rentals with customer and staff names.

SELECT customer_list.name AS customer, rental.rental_date, film.title, staff_list.name AS staff FROM rental JOIN inventory USING (inventory_id) JOIN film USING (film_id) JOIN customer_list ON customer_list.ID = rental.customer_id JOIN staff_list ON staff_list.ID = rental.staff_id ORDER BY rental.rental_date DESC LIMIT 20;
Get the database →

Sakila

Sales by store

Aggregate recorded rental payments by store.

SELECT store, manager, total_sales FROM sales_by_store ORDER BY total_sales DESC;
Get the database →