blob: eed58d0e78bbb4d7b1b254afc8ab2045089d3ee2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
-- Find all rentals in January 2024
select media.title, rentals.due_at, customers.first_name, customers.last_name
from rentals
inner join media on media.id = rentals.media_id
inner join customers on customers.id = rentals.customer_id
inner join categories on categories.id = media.category_id
where rentals.rented_at > '2024-01-01 00:00:00'
and rentals.due_at < '2024-02-01 00:00:00';
-- Find all rentals for Documentaries
select media.title, rentals.due_at, customers.first_name, customers.last_name
from rentals
inner join media on media.id = rentals.media_id
inner join customers on customers.id = rentals.customer_id
inner join categories on categories.id = media.category_id
and categories.title = 'Documentary';
-- Find all media in the Action category
select media.*
from media
inner join categories on categories.id = media.category_id
and categories.title = 'Action';
|