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

done #234

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

done #234

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
52 changes: 52 additions & 0 deletions lab_sql_joins.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Challenge 1

SELECT category.name, SUM(film_category.film_id)
FROM film_category
LEFT JOIN category
ON film_category.category_id = category.category_id
GROUP BY category.name
ORDER BY category.name;

# Challenge 2

SELECT
store.store_id,
city.city,
country.country
FROM store
LEFT JOIN address ON store.address_id = address.address_id
LEFT JOIN city ON address.city_id = city.city_id
LEFT JOIN country ON city.country_id = country.country_id;

# Challenge 3

SELECT
store.store_id,
SUM(payment.amount)
FROM store
LEFT JOIN customer ON store.store_id = customer.store_id
LEFT JOIN payment ON customer.customer_id = payment.customer_id
GROUP BY store.store_id;

# Challenge 4/5

SELECT
category.name,
AVG(film.length)
FROM category
LEFT JOIN film_category ON category.category_id = film_category.category_id
LEFT JOIN film ON film_category.film_id = film.film_id
GROUP BY category.name
ORDER BY AVG(film.length) desc;

# Challenge 7

SELECT
film.title,
store.store_id
FROM film
LEFT JOIN inventory ON film.film_id = inventory.film_id
LEFT JOIN store ON inventory.store_id = store.store_id
WHERE film.title = "Academy Dinosaur";