RazorBlade57

Untitled

Sep 18th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. -- Problem #1
  2. USE ap;
  3.  
  4. SELECT
  5. product_code,
  6. product_name,
  7. list_price,
  8. discount_percent
  9.  
  10. FROM my_guitar_shop.products
  11.  
  12. ORDER BY list_price DESC;
  13.  
  14. -- Problem #2
  15. SELECT CONCAT(last_name, ', ', first_name)
  16. AS Full_Name FROM my_guitar_shop.customers
  17. WHERE 'M' < last_name
  18. ORDER BY last_name ASC;
  19.  
  20. -- Problem #3
  21. SELECT
  22. product_name,
  23. list_price,
  24. date_added
  25. FROM my_guitar_shop.products
  26. WHERE list_price > 500 and list_price < 2000
  27. ORDER BY date_added DESC;
  28.  
  29. -- Problem #4
  30. SELECT
  31. product_name,
  32. list_price,
  33. discount_percent,
  34. CAST((list_price * (discount_percent/100)) AS DECIMAL(6,2)) AS discount_amount,
  35. CAST(list_price - (list_price * (discount_percent/100)) AS DECIMAL(6,2)) AS discount_price
  36. FROM my_guitar_shop.products
  37. ORDER BY discount_price DESC
  38. LIMIT 5;
  39.  
  40. -- Problem #5
  41. SELECT
  42. item_id,
  43. item_price,
  44. discount_amount,
  45. quantity,
  46. (item_price * quantity) AS price_total,
  47. (discount_amount * quantity) AS discount_total,
  48. (price_total - discount_total) * quantity AS item_total
  49. FROM my_guitar_shop.order_items
  50. WHERE item_total > 500
  51. ORDER BY item_total DESC;
Advertisement
Add Comment
Please, Sign In to add comment