Skip to content
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
34 changes: 33 additions & 1 deletion 4-multiple-tables/27_online_shop.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
-- Online Shop 🛍️
-- Codédex
-- Write code below 💖
select * from orders;
select * from products;
select * from customers;

select * from products
where inventory <=50;

select * from products
where inventory >50;


SELECT orders.id as order_id,
orders.date,
customers.name as customer,
products.name as product
from orders
join customers
on orders.customer_id = customers.id
join products
on orders.customer_id= products.id
where orders.fulfilled =1
order by orders.date;


SELECT
date,SUM(products.price) AS total_sales
FROM orders
JOIN products
ON orders.item_id = products.id
WHERE orders.fulfilled = 1 -- count only fulfilled orders
GROUP BY orders.date
ORDER BY total_sales DESC;

-- No solution for this one yet! :)