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-code-subqueries.sql 504B

1234567891011121314151617181920212223242526272829303132333435
  1. -- Exercise 1
  2. SELECT DISTINCT category_name
  3. FROM categories
  4. WHERE category_id IN
  5. (SELECT category_id
  6. FROM products)
  7. ORDER BY category_name
  8. -- Exercise 2
  9. SELECT product_name, list_price
  10. FROM products
  11. WHERE list_price >
  12. (SELECT AVG(list_price)
  13. FROM products)
  14. ORDER BY list_price DESC;
  15. -- Exercise 3
  16. SELECT category_name
  17. FROM categories
  18. WHERE NOT EXISTS
  19. (SELECT *
  20. FROM products
  21. WHERE category_id = categories.category_id);
  22. -- Exercise 4
  23. ???
  24. -- Exercise 4 Part 2
  25. ???
  26. -- Exercise 5
  27. ???
  28. -- Exercise 6
  29. ???