From 22427640037a98f21f55da5dbb96059fc235a978 Mon Sep 17 00:00:00 2001 From: Mohammadreza <104798944+Mohammadrezanafar@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:56:18 +0000 Subject: [PATCH 1/2] 2 exercise compeleted --- 2-exercises/package-lock.json | 6 ++++++ 2-exercises/task.md | 40 +++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 2-exercises/package-lock.json diff --git a/2-exercises/package-lock.json b/2-exercises/package-lock.json new file mode 100644 index 00000000..4042d4b2 --- /dev/null +++ b/2-exercises/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "2-exercises", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/2-exercises/task.md b/2-exercises/task.md index c48d2286..de6eac34 100644 --- a/2-exercises/task.md +++ b/2-exercises/task.md @@ -7,6 +7,7 @@ In this homework, you are going to work with an ecommerce database. In this data Below you will find a set of tasks for you to complete to set up a database for an e-commerce app. To submit this homework write the correct commands for each question here: + ```sql @@ -35,16 +36,47 @@ 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 + 2. Retrieve all the customers in ascending name sequence + + 3. Retrieve all the products whose name contains the word `socks` -4. Retrieve all the products which cost more than 100 showing product id, name, unit price and supplier id. + +4. Retrieve all the products which cost more than 100 showing +product id, name, unit price and supplier id. + + 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). + +8. Retrieve all orders, including order items, from customer ID `1`. Include order id, reference, date and total cost (calculated as quantity \* unit price). + + + 9. Retrieve all orders, including order items, from customer named `Hope Crosby` + + 10. Retrieve all the products in the order `ORD006`. The result should only contain the columns `product_name`, `unit_price` and `quantity`. + + + 11. Retrieve 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`. -12. Retrieve the names of all customers who bought a product from a supplier based in China. -13. List all orders giving customer name, order reference, order date and order total amount (quantity * unit price) in descending order of total. + +12. Retrieve the names of all customers who bought a product from a supplier based in China. + +13. List all orders giving customer name, order reference, order date and order total amount (quantity \* unit price) in descending order of total. + From 6fc033f0c4542c8f77452b7edddc59e9c3937b5c Mon Sep 17 00:00:00 2001 From: Mohammadreza <104798944+Mohammadrezanafar@users.noreply.github.com> Date: Tue, 14 Feb 2023 23:20:45 +0000 Subject: [PATCH 2/2] Done --- 2-exercises/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2-exercises/task.md b/2-exercises/task.md index de6eac34..b2e02307 100644 --- a/2-exercises/task.md +++ b/2-exercises/task.md @@ -45,7 +45,7 @@ Once you understand the database that you are going to work with, solve the foll 4. Retrieve all the products which cost more than 100 showing product id, name, unit price and supplier id. @@ -74,7 +74,7 @@ WHERE name ='Hope Crosby'; --> 11. Retrieve 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`. - + 12. Retrieve the names of all customers who bought a product from a supplier based in China.