From 24ae361e8de9291c4015101e0dfff6b736ab4373 Mon Sep 17 00:00:00 2001 From: Selm-a <156334821+Selm-a@users.noreply.github.com> Date: Sun, 25 Feb 2024 16:24:48 +0100 Subject: [PATCH 1/4] pushing lab --- lab-sql-2.sql | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lab-sql-2.sql diff --git a/lab-sql-2.sql b/lab-sql-2.sql new file mode 100644 index 0000000..a44cea7 --- /dev/null +++ b/lab-sql-2.sql @@ -0,0 +1,37 @@ +use sakila; + +select * from actor; +select * from actor where (first_name = "Scarlett"); +select * from actor where (last_name = "Johansson"); + +#3 How many films (movies) are available for rent? +#4 How many films have been rented? +##What is the shortest and longest rental period? + +select * from rental; +select max(datediff(return_date, rental_date)) from rental; +select min(datediff(return_date, rental_date)) from rental; + +#What are the shortest and longest movie duration? Name the values max_duration and min_duration. +select * from film; +select min(length) as min_duration from film limit 1; +select max(length) as max_duration from film limit 1; + +#What's the average movie duration? +select avg(length) from film; + +#What's the average movie duration expressed in format (hours, minutes)? +select *, convert(length, time) as movie_duration from film; + + +#How many movies longer than 3 hours? +select * from film; +select count(*) from film where length > 180; + +#Get the name and email formatted. Example: Mary SMITH - mary.smith@sakilacustomer.org. + +#What's the length of the longest film title? +select MAX(length(title)) as max_len from film; + + + From e151d4dd75a268215628f1bab59998f25bf21d66 Mon Sep 17 00:00:00 2001 From: Selm-a Date: Fri, 15 Mar 2024 13:28:05 +0100 Subject: [PATCH 2/4] Create lab-sql-2-reviewed.sql pushing lab --- lab-sql-2-reviewed.sql | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lab-sql-2-reviewed.sql diff --git a/lab-sql-2-reviewed.sql b/lab-sql-2-reviewed.sql new file mode 100644 index 0000000..da722dd --- /dev/null +++ b/lab-sql-2-reviewed.sql @@ -0,0 +1,42 @@ + +use sakila; + +#Select all the actors with the first name ‘Scarlett’. +#Select all the actors with the last name ‘Johansson’. + +select * from actor; +select * from actor where (first_name = "Scarlett"); +select * from actor where (last_name = "Johansson"); + +#3 How many films (movies) are available for rent? +#4 How many films have been rented? +##What is the shortest and longest rental period? + +select * from rental; +select max(datediff(return_date, rental_date)) from rental; +select min(datediff(return_date, rental_date)) from rental; + +#What are the shortest and longest movie duration? Name the values max_duration and min_duration. +select * from film; +select min(length) as min_duration from film limit 1; +select max(length) as max_duration from film limit 1; + +#What's the average movie duration? +select avg(length) from film; + +#What's the average movie duration expressed in format (hours, minutes)? !!!!!!! +select *, convert(length, time) as movie_duration from film; +select SEC_TO_TIME(avg(length))/60 as film_duration from film; + +#How many movies longer than 3 hours? +select * from film; +select count(*) from film where length > 180; + +#Get the name and email formatted. Example: Mary SMITH - mary.smith@sakilacustomer.org. !!!!!!!! +select * from customer; +select (concat(lower(first_name),".", lower(last_name), "@sakilacustomer.org" )) as customer_email from customer ; + + +#What's the length of the longest film title? +select MAX(length(title)) as max_len from film; + From e2cc9029ba1a34f7afd1e98394f5f5ae7864c8ad Mon Sep 17 00:00:00 2001 From: Selm-a Date: Fri, 15 Mar 2024 13:32:05 +0100 Subject: [PATCH 3/4] Revert "Create lab-sql-2-reviewed.sql" This reverts commit e151d4dd75a268215628f1bab59998f25bf21d66. --- lab-sql-2-reviewed.sql | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 lab-sql-2-reviewed.sql diff --git a/lab-sql-2-reviewed.sql b/lab-sql-2-reviewed.sql deleted file mode 100644 index da722dd..0000000 --- a/lab-sql-2-reviewed.sql +++ /dev/null @@ -1,42 +0,0 @@ - -use sakila; - -#Select all the actors with the first name ‘Scarlett’. -#Select all the actors with the last name ‘Johansson’. - -select * from actor; -select * from actor where (first_name = "Scarlett"); -select * from actor where (last_name = "Johansson"); - -#3 How many films (movies) are available for rent? -#4 How many films have been rented? -##What is the shortest and longest rental period? - -select * from rental; -select max(datediff(return_date, rental_date)) from rental; -select min(datediff(return_date, rental_date)) from rental; - -#What are the shortest and longest movie duration? Name the values max_duration and min_duration. -select * from film; -select min(length) as min_duration from film limit 1; -select max(length) as max_duration from film limit 1; - -#What's the average movie duration? -select avg(length) from film; - -#What's the average movie duration expressed in format (hours, minutes)? !!!!!!! -select *, convert(length, time) as movie_duration from film; -select SEC_TO_TIME(avg(length))/60 as film_duration from film; - -#How many movies longer than 3 hours? -select * from film; -select count(*) from film where length > 180; - -#Get the name and email formatted. Example: Mary SMITH - mary.smith@sakilacustomer.org. !!!!!!!! -select * from customer; -select (concat(lower(first_name),".", lower(last_name), "@sakilacustomer.org" )) as customer_email from customer ; - - -#What's the length of the longest film title? -select MAX(length(title)) as max_len from film; - From 0509320254c572ff0a538e23f9751e19e43464ab Mon Sep 17 00:00:00 2001 From: Selm-a Date: Fri, 15 Mar 2024 13:49:45 +0100 Subject: [PATCH 4/4] Create lab-sql-2-reviewed.sql pushing lab --- lab-sql-2-reviewed.sql | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 lab-sql-2-reviewed.sql diff --git a/lab-sql-2-reviewed.sql b/lab-sql-2-reviewed.sql new file mode 100644 index 0000000..93eed20 --- /dev/null +++ b/lab-sql-2-reviewed.sql @@ -0,0 +1,40 @@ +use sakila; + +#Select all the actors with the first name ‘Scarlett’. +#Select all the actors with the last name ‘Johansson’. + +select * from actor; +select * from actor where (first_name = "Scarlett"); +select * from actor where (last_name = "Johansson"); + +#3 How many films (movies) are available for rent? +#4 How many films have been rented? +##What is the shortest and longest rental period? + +select * from rental; +select max(datediff(return_date, rental_date)) from rental; +select min(datediff(return_date, rental_date)) from rental; + +#What are the shortest and longest movie duration? Name the values max_duration and min_duration. +select * from film; +select min(length) as min_duration from film limit 1; +select max(length) as max_duration from film limit 1; + +#What's the average movie duration? +select avg(length) from film; + +#What's the average movie duration expressed in format (hours, minutes)? !!!!!!! +select *, convert(length, time) as movie_duration from film; +select SEC_TO_TIME(avg(length))/60 as film_duration from film; + +#How many movies longer than 3 hours? +select * from film; +select count(*) from film where length > 180; + +#Get the name and email formatted. Example: Mary SMITH - mary.smith@sakilacustomer.org. !!!!!!!! +select * from customer; +select (concat(lower(first_name),".", lower(last_name), "@sakilacustomer.org" )) as customer_email from customer ; + + +#What's the length of the longest film title? +select MAX(length(title)) as max_len from film; \ No newline at end of file