Skip to content
Closed
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
47 changes: 47 additions & 0 deletions E-Commerce/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,59 @@ erDiagram
Write SQL queries to complete the following tasks:

- [ ] List all the products whose name contains the word "socks"
select product_name from products where product_name LIKE '%socks%'

- [ ] List all the products which cost more than 100 showing product id, name, unit price, and supplier id
select prod_id, product_name, unit_price, supp_id from products
inner join product_availability
on product_availability.prod_id = products.id
where unit_price > 100

- [ ] List the 5 most expensive products
select product_name, unit_price from products
inner join product_availability
on product_availability.prod_id = products.id
ORDER BY unit_price DESC limit 5;

- [ ] List all the products sold by suppliers based in the United Kingdom. The result should only contain the columns product_name and supplier_name
select product_name, supplier_name from products
inner join product_availability
on product_availability.prod_id = products.id
inner join suppliers
on product_availability.supp_id = suppliers.id
where country = 'United Kingdom'

- [ ] List all orders, including order items, from customer named Hope Crosby
select * from orders
inner join order_items
on orders.id = order_items.order_id
inner join customers on customer_id = customers.id
where name = 'Hope Crosby'

- [ ] List all the products in the order ORD006. The result should only contain the columns product_name, unit_price, and quantity
select product_name, unit_price, quantity
from orders
inner join order_items
on orders.id = order_items.order_id
inner join product_availability
on order_items.product_id = product_availability.prod_id
inner join products
on product_availability.prod_id = products.id
where order_reference like '%ORD006%';

- [ ] List all the products with their supplier for all orders of all customers. The result should only contain the columns name (from customer), order_reference, order_date, product_name, supplier_name, and quantity
select name, order_reference, order_date, product_name, supplier_name, quantity
from products
inner join product_availability
on products.id = product_availability.prod_id
inner join order_items
on product_availability.prod_id = order_items.product_id
inner join orders
on order_items.order_id = orders.id
inner join suppliers
on product_availability.supp_id = suppliers.id
inner join customers
on orders.customer_id = customers.id;

## Acceptance Criteria

Expand Down