You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

How-to-retrieve-data-from-two-or-more-tables.sql 1016B

1234567891011121314151617181920212223242526272829303132333435
  1. -- Exercise 1
  2. SELECT category_name, product_name, list_price
  3. FROM categories JOIN products
  4. ORDER BY category_name, list_price ASC;
  5. -- Exercise 2
  6. SELECT first_name, last_name, line1, city, state, zip_code
  7. FROM customers c1 JOIN addresses c2 ON c1.customer_id = c2.customer_id
  8. WHERE email_address = 'allan.sherwood@yahoo.com';
  9. -- Exercise 3
  10. SELECT first_name, last_name, line1, city, state, zip_code
  11. FROM customers c1 JOIN addresses c2 ON c1.customer_id = c2.customer_id
  12. ?????
  13. -- Exercise 4
  14. SELECT last_name, first_name, order_date, product_name, item_price, discount_amount, quantity
  15. FROM customers c
  16. JOIN orders o ON c.customer_id = o.customer_id
  17. JOIN order_items oi ON o.order_id = oi.order_id
  18. JOIN products p ON oi.product_id = p.product_id
  19. ORDER BY last_name, order_date, product_name;
  20. -- Exercise 5
  21. SELECT DISTINCT p1.product_name, p2.list_price
  22. FROM products p1 JOIN products p2
  23. ON p1.product_id != p2.product_id
  24. AND p1.list_price = p2.list_price
  25. ORDER BY product_name;
  26. -- Exercise 6
  27. ???
  28. -- Exercise 7
  29. ???