Advertisement
RazorBlade57

Untitled

Sep 18th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 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. (((item_price * quantity) - (discount_amount * quantity))) AS item_total
  49. FROM my_guitar_shop.order_items
  50. WHERE (((item_price * quantity) - (discount_amount * quantity)) * quantity) > 500
  51. ORDER BY (((item_price * quantity) - (discount_amount * quantity)) * quantity) DESC;
  52.  
  53. -- Problem #6
  54.  
  55. SELECT
  56. order_id,
  57. order_date,
  58. ship_date
  59. FROM my_guitar_shop.orders
  60. Where ship_date is null;
  61.  
  62. -- Problem #7
  63.  
  64. SELECT
  65. NOW() as today_unformatted,
  66. DATE_FORMAT(NOW(),'%d-%b-%Y') as today_formatted
  67.  
  68. FROM my_guitar_shop.orders;
  69.  
  70. -- Problem #8
  71. SELECT
  72. [100 AS price],
  73. .07 as tax_rate,
  74. (price * tax_rate) as tax_amount
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement