1234567891011121314151617181920212223242526272829303132333435363738 |
- -- Exercise 1
- SELECT COUNT(order_id) AS order_count, SUM(tax_amount) AS tax_total
- FROM orders;
-
- -- Exercise 2
- SELECT category_name, COUNT(product_name) AS product_count, sum(list_price)
- FROM categories c JOIN products p
- ON c.category_id = p.category_id.
- ORDER BY category_name ASC;
-
- -- Exercise 3
- SELECT email_adress,SUM(item_price*quantity) AS item_price_total, SUM(discount_amount*quantity) AS discount_amount
- FROM administrators c JOIN order_items l
- ON c.admin_id = l.admin_id
- ORDER BY item_price DESC;
-
- -- Exercise 4
- SELECT email_adress, COUNT(order_id) AS order_count, SUM((ship_amount-tax_amount)*quantity) AS order_total
- FROM administrators c JOIN orders o
- ON c.admin_id_id = o.admin_id
- WHERE admin_id > 1
- ORDER BY SUM(list_price) DESC;
-
- -- Exercise 5
- SELECT email_adress, COUNT(order_id) AS order_count, SUM((ship_amount-tax_amount)*quantity) AS order_total
- FROM administrators c JOIN orders o
- ON c.admin_id_id = o.admin_id
- WHERE order_id >= 400
- ORDER BY SUM(list_price) DESC;
-
- -- Exercise 6
-
-
- -- Exercise 7
- SELECT email_adress, sum(product_id) AS number_of_products
- FROM administrators a JOIN products p
- ON a.admin_id = p.admin_id
- ORDER BY admin_id ASC;
|