Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab9feito[joao almeida] #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions lab9feito.sql
Original file line number Diff line number Diff line change
@@ -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;