Skip to content
This repository was archived by the owner on Aug 17, 2024. It is now read-only.
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
10 changes: 10 additions & 0 deletions 2-exercises/task.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,20 @@ Open the file `cyf_ecommerce.sql` in VSCode and examine the SQL code. Take a pie
Once you understand the database that you are going to work with, solve the following challenge by writing SQL queries using everything you learned about SQL:

1. Retrieve all the customers' names and addresses who live in the United States
===> SELECT name, address from customers where country='United States';

2. Retrieve all the customers in ascending name sequence
===> SELECT * from customers order by name asc;

3. Retrieve all the products whose name contains the word `socks`
===> SELECT * from products where product_name like '%socks%';

4. Retrieve all the products which cost more than 100 showing product id, name, unit price and supplier id.
===> select product_availability.prod_id,product_availability.unit_price,products.product_name,suppliers.supplier_name from product_availability join products on (products.id=product_availability.prod_id)join suppliers on(suppliers.id=product_availability.supp_id)where product_availability.unit_price >100;

5. Retrieve the 5 most expensive products
===>

6. Retrieve all the products with their corresponding suppliers. The result should only contain the columns `product_name`, `unit_price` and `supplier_name`
7. Retrieve all the products sold by suppliers based in the United Kingdom. The result should only contain the columns `product_name` and `supplier_name`.
8. Retrieve all orders, including order items, from customer ID `1`. Include order id, reference, date and total cost (calculated as quantity * unit price).
Expand Down