From 8d8ef2abb2f193601a85460a70d1a1dfbfd27fe3 Mon Sep 17 00:00:00 2001 From: David Martins Date: Mon, 13 Nov 2023 14:44:50 +0000 Subject: [PATCH 1/2] labsql2done --- LAB 2 SQL.sql | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 LAB 2 SQL.sql diff --git a/LAB 2 SQL.sql b/LAB 2 SQL.sql new file mode 100644 index 0000000..43d6066 --- /dev/null +++ b/LAB 2 SQL.sql @@ -0,0 +1,67 @@ +-- Select all the actors with the first name ‘Scarlett’. + +SELECT * +FROM sakila.actor +WHERE first_name = 'Scarlett'; + +-- Select all the actors with the last name ‘Johansson’. +SELECT * +FROM sakila.actor +WHERE last_name = 'Johansson'; + +-- How many films (movies) are available for rent? + +SELECT count(rental_id) +FROM sakila.rental; + +-- How many films have been rented? + +select count(rental_date) +from sakila.rental; + +-- What is the shortest and longest rental period? + +SELECT MIN(rental_duration) AS shortest_rental_period +FROM sakila.film; + +SELECT max(rental_duration) AS longest_rental_period +FROM sakila.film; + +-- What's the average movie duration? + +SELECT AVG(length) AS average_movie_duration +FROM sakila.film; + +-- What's the average movie duration expressed in format (hours, minutes)? +SELECT + CONCAT( + FLOOR(AVG(length) / 60), ' hours ', + AVG(length) % 60, ' minutes' + ) AS average_movie_duration +FROM sakila.film; + +-- How many movies longer than 3 hours? + +SELECT COUNT(*) +FROM sakila.film +WHERE length > 180; + +-- Get the name and email formatted. Example: Mary SMITH - mary.smith@sakilacustomer.org. + +SELECT + CONCAT(first_name, ' ', last_name, ' - ', email) AS formatted_name_and_email +FROM + sakila.customer; + + -- What's the length of the longest film title? + SELECT MAX(LENGTH(title)) AS longest_title_length +FROM sakila.film; + + + + + + + + + From ec3a81bbc3305c0ae26d8e56898f9e8d1a0ebdda Mon Sep 17 00:00:00 2001 From: David Martins Date: Mon, 13 Nov 2023 14:53:24 +0000 Subject: [PATCH 2/2] labsql2done --- LAB 2 SQL.sql | 67 --------------------------------------------------- lab-sql-2 | 1 + 2 files changed, 1 insertion(+), 67 deletions(-) delete mode 100644 LAB 2 SQL.sql create mode 160000 lab-sql-2 diff --git a/LAB 2 SQL.sql b/LAB 2 SQL.sql deleted file mode 100644 index 43d6066..0000000 --- a/LAB 2 SQL.sql +++ /dev/null @@ -1,67 +0,0 @@ --- Select all the actors with the first name ‘Scarlett’. - -SELECT * -FROM sakila.actor -WHERE first_name = 'Scarlett'; - --- Select all the actors with the last name ‘Johansson’. -SELECT * -FROM sakila.actor -WHERE last_name = 'Johansson'; - --- How many films (movies) are available for rent? - -SELECT count(rental_id) -FROM sakila.rental; - --- How many films have been rented? - -select count(rental_date) -from sakila.rental; - --- What is the shortest and longest rental period? - -SELECT MIN(rental_duration) AS shortest_rental_period -FROM sakila.film; - -SELECT max(rental_duration) AS longest_rental_period -FROM sakila.film; - --- What's the average movie duration? - -SELECT AVG(length) AS average_movie_duration -FROM sakila.film; - --- What's the average movie duration expressed in format (hours, minutes)? -SELECT - CONCAT( - FLOOR(AVG(length) / 60), ' hours ', - AVG(length) % 60, ' minutes' - ) AS average_movie_duration -FROM sakila.film; - --- How many movies longer than 3 hours? - -SELECT COUNT(*) -FROM sakila.film -WHERE length > 180; - --- Get the name and email formatted. Example: Mary SMITH - mary.smith@sakilacustomer.org. - -SELECT - CONCAT(first_name, ' ', last_name, ' - ', email) AS formatted_name_and_email -FROM - sakila.customer; - - -- What's the length of the longest film title? - SELECT MAX(LENGTH(title)) AS longest_title_length -FROM sakila.film; - - - - - - - - - diff --git a/lab-sql-2 b/lab-sql-2 new file mode 160000 index 0000000..94ec971 --- /dev/null +++ b/lab-sql-2 @@ -0,0 +1 @@ +Subproject commit 94ec971ee7ee1c4f7888fcea10648238df74189e