Retrieving Film Titles and Rental Rates
SELECT title AS "Movie Title", rental_rate AS "Rate"
FROM film;
This query displays film titles and their rental rates with readable column names.
Listing Customer Names and Emails
SELECT first_name AS "First Name",
last_name AS "Last Name",
email
FROM customer;
This shows customer names along with their email addresses.
Sorting Films by Rental Rate
SELECT title, rental_rate
FROM film
ORDER BY rental_rate DESC, title ASC;
Films are sorted by rental rate from highest to lowest, and then by title.
Sorting Actor Names
SELECT first_name, last_name
FROM actor
ORDER BY last_name, first_name;
Actors are listed in order of last name and then first name.
Getting Unique Replacement Costs
SELECT DISTINCT replacement_cost
FROM film;
This query returns only different replacement cost values.
Displaying Film Duration
SELECT title, length AS "Duration (min)"
FROM film;
Shows film titles along with their duration in minutes.
Customer Active Status
SELECT first_name, last_name, active AS "Is Active"
FROM customer;
Displays whether each customer is active or not.
Film Categories in Order
SELECT name
FROM category
ORDER BY name;
Lists all film categories alphabetically.
Films by Length
SELECT title, length
FROM film
ORDER BY length DESC;
Shows films from longest to shortest.
Actors Sorted by First Name Descending
SELECT first_name, last_name
FROM actor
ORDER BY first_name DESC;
Actors are sorted in reverse alphabetical order by first name.
Unique Film Ratings
SELECT DISTINCT rating
FROM film;
Displays all different ratings available.
Unique Rental Durations
SELECT DISTINCT rental_duration
FROM film;
Shows all unique rental durations.
Customer ID and Active Status
SELECT DISTINCT customer_id, active
FROM customer
ORDER BY customer_id;
Lists customer IDs along with their active status.
Earliest Rental Date per Customer
SELECT customer_id, MIN(rental_date) AS rental_date
FROM rental
GROUP BY customer_id
ORDER BY customer_id;
Finds the first rental date for each customer.
Ten Shortest Films
SELECT title, length
FROM film
ORDER BY length
LIMIT 10;
Displays the ten shortest films.
Top Five Customers by ID
SELECT first_name, last_name
FROM customer
ORDER BY customer_id DESC
LIMIT 5;
Shows the customers with the highest IDs.
Unique Store IDs
SELECT DISTINCT store_id
FROM inventory;
Lists all store IDs without duplicates.
Sorted Replacement Costs
SELECT DISTINCT replacement_cost
FROM film
ORDER BY replacement_cost;
Displays replacement costs in increasing order.
First Rental Date per Store
SELECT store_id, MIN(rental_date) AS rental_date
FROM rental
GROUP BY store_id
ORDER BY store_id;
Shows the first rental date for each store.
Unique Ratings in Order
SELECT DISTINCT rating
FROM film
ORDER BY rating;
Lists all ratings alphabetically.
Films by Rating and Length
SELECT title, rating, length
FROM film
ORDER BY rating, length DESC;
Sorts films by rating and then by length.
Actor Names with Mixed Sorting
SELECT first_name, last_name
FROM actor
ORDER BY last_name ASC, first_name DESC;
Actors are sorted by last name and then reverse order of first name.
Films by Cost and Rate
SELECT title, replacement_cost, rental_rate
FROM film
ORDER BY replacement_cost ASC, rental_rate DESC;
Sorts films by replacement cost and rental rate.
Customer Names Sorted
SELECT first_name, last_name
FROM customer
ORDER BY last_name ASC, first_name DESC;
Customers are sorted by last name and reverse first name.
Rentals Sorted by Customer and Date
SELECT *
FROM rental
ORDER BY customer_id, rental_date DESC;
Shows rentals sorted by customer and latest rental first.
Films by Rental Duration
SELECT title, rental_duration
FROM film
ORDER BY rental_duration ASC, title DESC;
Sorts films by rental duration and title.
Top comments (0)