Lesson 1 of 0
In Progress

SQL Case Study 1: Tiny Shop Sales

Kedeisha May 15, 2023

Overview

Welcome to our first SQL case study.

Those who submit an entry will be eligible to win a free copy of SQL For Data Analytics by Packt! The more weeks you participate, the more chances you get to win!

There is no deadline for submission.

Submission Instructions

Make a LinkedIn or twitter post with a screenshot or PDF of your answers. You can explain your thought process if you’d like. Just make sure to tag the Data in Motion LLC LinkedIn page or Twitter page.

Overview

This case study uses PostgreSQL. To successfully answer all the questions you should have been exposed to the following areas of SQL:

  • Basic aggregations
  • CASE WHEN statements
  • Window Functions
  • Joins
  • Date time functions
  • CTEs

Questions

  1. Which product has the highest price? Only return a single row.
  2. Which customer has made the most orders?
  3. What’s the total revenue per product?
  4. Find the day with the highest revenue.
  5. Find the first order (by date) for each customer.
  6. Find the top 3 customers who have ordered the most distinct products
  7. Which product has been bought the least in terms of quantity?
  8. What is the median order total?
  9. For each order, determine if it was ‘Expensive’ (total over 300), ‘Affordable’ (total over 100), or ‘Cheap’.
  10. Find customers who have ordered the product with the highest price.

DB Fiddle Instructions

Click ‘Edit on DB Fiddle’ to be taken to the in browser SQL playground where you can run your queries.