From d2e0fae660172255e10c6b0e97d7b230faaa257b Mon Sep 17 00:00:00 2001 From: Davi Santos Date: Tue, 7 May 2024 17:42:45 -0300 Subject: [PATCH] Add files via upload --- [Davi]lab-sql-9.sql | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 [Davi]lab-sql-9.sql diff --git a/[Davi]lab-sql-9.sql b/[Davi]lab-sql-9.sql new file mode 100644 index 0000000..4980601 --- /dev/null +++ b/[Davi]lab-sql-9.sql @@ -0,0 +1,28 @@ +-- Create a table rentals_may to store the data from rental table with information for the month of May. +-- Insert values in the table rentals_may using the table rental, filtering values only for the month of May. +CREATE TABLE RENTALS_MAY +SELECT * +FROM SAKILA.RENTAL +WHERE MONTH(RENTAL_DATE) = 05; + +SELECT * FROM RENTALS_MAY; + +-- Create a table rentals_june to store the data from rental table with information for the month of June. +-- Insert values in the table rentals_june using the table rental, filtering values only for the month of June. +CREATE TABLE RENTALS_JUNE +SELECT * +FROM SAKILA.RENTAL +WHERE MONTH(RENTAL_DATE) = 06; + +SELECT * FROM RENTALS_JUNE; + +-- Check the number of rentals for each customer for May. +SELECT COUNT(RENTAL_ID) AS RENTALS_IN_MAY +FROM RENTALS_MAY; + +-- Check the number of rentals for each customer for June. +SELECT COUNT(RENTAL_ID) AS RENTALS_IN_JUNE +FROM RENTALS_JUNE; + +-- Create a Python connection with SQL database and retrieve the results of the last two queries +-- (also mentioned below) as dataframes: \ No newline at end of file