Additional SQL Exercises

These exercises are for you to practice SQL and will not be graded. Feel free to share your solutions in the class forum.

Complete the following queries using the Store database.

[Joins and Functions] 

  1. List the names of the customers who bought CPU products last month.
  2. List the names of the customers who bought both CPU and hard drives last month.
  3. List the names of the customers who have not bought anything since 2004.
  4. List the products that nobody has bought in the last three months.
  5. Find all the products ordered by John Doe, and order the results first by the date they were ordered and then by the date they were shipped.
  6. Find all the products that are more expensive than Intel Pentium D.
  7. List all the products that were shipped to zip code 90001 yesterday.

[Aggregations]

  1. List the monthly sales of this year so far.
  2. List the ID, total number of items, and total dollar amount of each order.
  3. Find the top 3 selling products last month in terms of number of units sold.
  4. Find the top 3 selling products last month in terms of total revenue generated.
  5. Find the top 3 customer last year in terms of number of orders placed.
  6. Find the top 3 customer last year in terms of total dollar amount spent.