DEV Community

Shreya Princy
Shreya Princy

Posted on

DB-TASK-001

  1. Film titles with rental rates:- SELECT title AS "Movie Title", rental_rate AS "Rate" FROM film;
  2. Customer names and email:-

SELECT first_name AS "First Name", last_name AS "Last Name", email FROM customer;

  1. Films sorted by rental rate (desc), then title:-

SELECT title, rental_rate FROM film ORDER BY rental_rate DESC, title ASC;

  1. Actor names sorted by last name, then first name:- SELECT first_name, last_name FROM actor ORDER BY last_name ASC, first_name ASC;
  2. Unique replacement costs:- SELECT DISTINCT replacement_cost FROM film;
  3. Film title and duration:- SELECT title, length AS "Duration (min)" FROM film;
  4. Customer active status:- SELECT first_name, last_name, active AS "Is Active" FROM customer;
  5. Film categories sorted alphabetically:- SELECT nameFROM category ORDER BY name ASC;
  6. Films by length (descending):- SELECT title, length FROM film ORDER BY length DESC;
  7. Actor names sorted by first name (descending) SELECT first_name, last_name FROM actor ORDER BY first_name DESC;
  8. Unique ratings:- SELECT DISTINCT rating FROM film;
  9. Unique rental durations:- SELECT DISTINCT rental_duration FROM film;
  10. First unique customer ID based on active status:- SELECT DISTINCT customer_id, active FROM customer ORDER BY customer_id LIMIT 1;
  11. Earliest rental date for each customer:- SELECT customer_id, MIN(rental_date) AS rental_date FROM rental GROUP BY customer_id ORDER BY customer_id;
  12. 10 shortest films SELECT title, length FROM film ORDER BY length ASC LIMIT 10;
  13. Top 5 customers with highest customer_id:- SELECT first_name, last_name FROM customer ORDER BY customer_id DESC LIMIT 5;
  14. Unique store IDs from inventory:- SELECT DISTINCT store_id FROM inventory;
  15. Unique replacement_cost sorted ascending SELECT DISTINCT replacement_cost FROM film ORDER BY replacement_cost ASC;
  16. First rental date for each store:- SELECT i.store_id, MIN(r.rental_date) AS rental_date FROM rental r JOIN inventory i ON r.inventory_id = i.inventory_id GROUP BY i.store_id ORDER BY i.store_id;
  17. Unique film ratings sorted alphabetically:- SELECT DISTINCT rating FROM film ORDER BY rating ASC;
  18. Films by rating (asc) and length (desc):- SELECT title, rating, length FROM film ORDER BY rating ASC, length DESC;
  19. Actor names sorted last asc, first desc SELECT first_name, last_name FROM actor ORDER BY last_name ASC, first_name DESC;
  20. Films by replacement_cost asc and rental_rate desc SELECT title, replacement_cost, rental_rate FROM film ORDER BY replacement_cost ASC, rental_rate DESC;
  21. Customers sorted last asc, first desc SELECT first_name, last_name FROM customer ORDER BY last_name ASC, first_name DESC;
  22. Rentals sorted by customer_id asc, rental_date desc SELECT * FROM rental ORDER BY customer_id ASC, rental_date DESC;
  23. Films ordered by rental_duration asc and title desc SELECT title, rental_duration FROM film ORDER BY rental_duration ASC, title DESC;

Top comments (0)