summaryrefslogtreecommitdiff
path: root/projects/3/queries.sql
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-01-13 22:47:09 -0700
committermo khan <mo@mokhan.ca>2025-01-13 22:47:09 -0700
commit3b7cc65e3fe5e66dcf77bee4045d9f5c7ce0f846 (patch)
tree6f34bf45733c4536509689e8ed663b2c83a3087b /projects/3/queries.sql
parente4cb765cd6a9b5932122a72ca4b142649858c37e (diff)
Split sql files
Diffstat (limited to 'projects/3/queries.sql')
-rw-r--r--projects/3/queries.sql22
1 files changed, 22 insertions, 0 deletions
diff --git a/projects/3/queries.sql b/projects/3/queries.sql
new file mode 100644
index 0000000..eed58d0
--- /dev/null
+++ b/projects/3/queries.sql
@@ -0,0 +1,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';