123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- -- Exercise 1
- SELECT product_name, list_price, date_added, discount_percent
- FROM products
- ORDER BY list_price DESC;
-
- -- Exercise 2
- SELECT first_name, last_name,
- CONCAT(first_name, ', ', last_name) AS last_name
- FROM customers
- WHERE last_name > 'M'
- ORDER BY last_name ASC;
-
- -- Exercise 3
- SELECT product_name, list_price, date_added
- FROM products
- WHERE list_price > 500 AND list_price < 2000
- ORDER BY date_added DESC;
-
- -- Exercise 4
- SELECT product_name, list_price, discount_percent,
- ROUND(((list_price * discount_percent) / 100), 2) AS discount_amount,
- ROUND(((list_price - (list_price * discount_percent) / 100)), 2) AS discount_price
- FROM products
- ORDER BY discount_price DESC
- LIMIT 5;
-
- -- Exercise 5
- SELECT item_id, item_price, discount_amount, quantity,
- item_price * quantity AS price_total,
- discount_amount * quantity AS discount_total,
- (item_price - discount_amount) * quantity AS item_total
- FROM order_items
- HAVING item_total > 500
- ORDER BY item_total DESC;
-
- -- Exercise 6
- SELECT order_id, order_date, ship_date
- FROM orders
- WHERE ship_date IS NULL;
-
- -- Exercise 7
- SELECT NOW() AS today_unformatted,
- DATE_FORMAT(NOW(), '%e-%b-%Y') AS today_formatted;
-
- -- Exercise 8
- SELECT 100 AS price, .07 AS tax_rate,
- 100 * .07 AS tax_amount,
- 100 + (100 * .07) AS total;
|