From c7f8da62a30ad96ff67d461b6bbe9c58d85e5877 Mon Sep 17 00:00:00 2001 From: JoaoAlmeida2024 Date: Thu, 9 May 2024 21:52:40 +0100 Subject: [PATCH] lab9feito --- lab9feito.sql | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lab9feito.sql diff --git a/lab9feito.sql b/lab9feito.sql new file mode 100644 index 0000000..ae95956 --- /dev/null +++ b/lab9feito.sql @@ -0,0 +1,41 @@ +-- Create a table rentals_may to store the data from rental table with information for the month of May. + +select * +from sakila.rental; + +CREATE TEMporary table sakila.rentals_may as +select * +from sakila.rental +where extract(month from rental_date) = 5; + +select * +from sakila.rentals_may; + +-- Insert values in the table rentals_may using the table rental, filtering values only for the month of May. + +-- Create a table rentals_june to store the data from rental table with information for the month of June. + +CREATE TEMporary table sakila.rentals_june as +select * +from sakila.rental +where extract(month from rental_date) = 6; + +select* +from sakila.rentals_june; + +-- Check the number of rentals for each customer for May. + +select customer_id, count(*) as +rental_count +from rentals_may +group by customer_id; + +-- Check the number of rentals for each customer for June. + +select customer_id, count(*) as +rental_count +from sakila.rentals_june +group by customer_id; + + +