Browse Source

'How-to-retrieve-data-from-a-single-table.sql' updaten

master
Hilco 2 years ago
parent
commit
1b11e12b55
1 changed files with 20 additions and 5 deletions
  1. 20
    5
      How-to-retrieve-data-from-a-single-table.sql

+ 20
- 5
How-to-retrieve-data-from-a-single-table.sql View File

@@ -1,24 +1,38 @@
-- Exercise 1
SELECT product_code, product_name, list_price, discount_percent
FROM products
ORDER BY list_price DESC;
ORDER BY list_price DESC

-- Exercise 2

SELECT CONCAT(last_name, ", ", first_name) AS full_name
FROM customers
WHERE last_name >= "M"
ORDER BY last_name

-- Exercise 3

SELECT product_name, list_price, date_added
FROM products
WHERE list_price BETWEEN 500 AND 2000
ORDER BY date_added DESC

-- Exercise 4

SELECT product_name, list_price, discount_percent,
ROUND((discount_percent/100) * list_price, 2) AS discount_amount,
ROUND(list_price - (discount_percent/100) * list_price, 2) AS discount_price
FROM products
ORDER BY discount_price DESC
LIMIT 5

-- Exercise 5


-- Exercise 6

SELECT order_id, order_date, ship_date
FROM orders
WHERE ship_date IS NULL

-- Exercise 7


-- Exercise 8
SELECT '100 (dollars)' AS price, '.07 (7 percent)' AS tax_rate, 7.00 AS tax_amount, 100 + (100 * 0.07) AS total

Loading…
Cancel
Save