Skip to content

AlysterF/8week-SQL-challenge

Repository files navigation

8 Week SQL challenge

The 8 week SQL challenge is a free challenge created by Danny Ma from Data with Danny. It has 8 funny case studies waiting for awesome SQL query solutions! If you want to know more about the challenge and Danny Ma (and I really recommend you do), feel free to access the 8 Week SQL Challenge Page.



All cases are going to be reviewed, due to my advances in SQL studies.

🍜 Case Study #1 - Danny's Diner 🍜

Case #1 details

Business Case

Danny wants to use the data to answer some questions about his customers and have some insights to improve his connection with his customers. He plans on using these insights to help him decide whether he should expand the existing customer loyalt program. It was provided a sample of his overall customer data due to privacy issues, but it should be enough to create fully functioning SQL queries. The data is organized in three entities and you can check more about it the entity diagram below.

Case questions
  1. What is the total amount each customer spent at the restaurant?
  2. How many days has each customer visited the restaurant?
  3. What was the first item from the menu purchased by each customer?
  4. What is the most purchased item on the menu and how many times was it purchased by all customers?
  5. Which item was the most popular for each customer?
  6. Which item was purchased first by the customer after they became a member?
  7. Which item was purchased just before the customer became a member?
  8. What is the total items and amount spent for each member before they became a member?
  9. If each $1 spent equates to 10 points and sushi has a 2x points multiplier - how many points would each customer have?
  10. In the first week after a customer joins the program (including their join date) they earn 2x points on all items, not just sushi - how many points do customer A and B have at the end of January?



🍕 Case Study #2 - Pizza Runner 🍕

Case #2 details

Business Case

Danny had a business idea to create a Pizza Empire! But it's not only a pizza delivery, it's a special pizza delivery Uberized. Danny collected a lot of data to start his new business, and he wants help to explore the data and answer some questions and get some insights that will help the business to be unique and assertive.

Case questions
A. Pizza Metrics
  1. How many pizzas were ordered?
  2. How many unique customer orders were made?
  3. How many successful orders were delivered by each runner?
  4. How many of each type of pizza was delivered?
  5. How many Vegetarian and Meatlovers were ordered by each customer?
  6. What was the maximum number of pizzas delivered in a single order?
  7. For each customer, how many delivered pizzas had at least 1 change and how many had no changes?
  8. How many pizzas were delivered that had both exclusions and extras?
  9. What was the total volume of pizzas ordered for each hour of the day?
  10. What was the volume of orders for each day of the week?
B. Runner and Customer Experience
  1. How many runners signed up for each 1 week period? (i.e. week starts 2021-01-01)
  2. What was the average time in minutes it took for each runner to arrive at the Pizza Runner HQ to pickup the order?
  3. Is there any relationship between the number of pizzas and how long the order takes to prepare?
  4. What was the average distance travelled for each customer?
  5. What was the difference between the longest and shortest delivery times for all orders?
  6. What was the average speed for each runner for each delivery and do you notice any trend for these values?
  7. What is the successful delivery percentage for each runner?
C. Ingredient Optimisation
  1. What are the standard ingredients for each pizza?
  2. What was the most commonly added extra?
  3. What was the most common exclusion?
  4. Generate an order item for each record in the customers_orders table in the format of one of the following:
    • Meat Lovers
    • Meat Lovers - Exclude Beef
    • Meat Lovers - Extra Bacon
    • Meat Lovers - Exclude Cheese, Bacon - Extra Mushroom, Peppers
  5. Generate an alphabetically ordered comma separated ingredient list for each pizza order from the customer_orders table and add a 2x in front of any relevant ingredients
    • For example: "Meat Lovers: 2xBacon, Beef, ... , Salami"
  6. What is the total quantity of each ingredient used in all delivered pizzas sorted by most frequent first?
D. Pricing and Ratings
  1. If a Meat Lovers pizza costs $12 and Vegetarian costs $10 and there were no charges for changes - how much money has Pizza Runner made so far if there are no delivery fees?
  2. What if there was an additional $1 charge for any pizza extras?
    • Add cheese is $1 extra
  3. The Pizza Runner team now wants to add an additional ratings system that allows customers to rate their runner, how would you design an additional table for this new dataset - generate a schema for this new table and insert your own data for ratings for each successful customer order between 1 to 5.
  4. Using your newly generated table - can you join all of the information together to form a table which has the following information for successful deliveries?
    • customer_id
    • order_id
    • runner_id
    • rating
    • order_time
    • pickup_time
    • Time between order and pickup
    • Delivery duration
    • Average speed
    • Total number of pizzas
  5. If a Meat Lovers pizza was $12 and Vegetarian $10 fixed prices with no cost for extras and each runner is paid $0.30 per kilometre traveled - how much money does Pizza Runner have left over after these deliveries?
E. Bonus Questions
  1. If Danny wants to expand his range of pizzas - how would this impact the existing data design? Write an INSERT statement to demonstrate what would happen if a new Supreme pizza with all the toppings was added to the Pizza Runner menu.



🥑 Case Study #3 - Foodie-Fi 🥑

Case #3 details

Business Case

Danny and some friends created Foodie-Fi, a startup of streaming focused only on cooking shows! The startup sells monthly and annual subscriptions, and was created as a data driven company. This case study focus on using subscription style digital data to answer important business questions.

Case questions
A. Customer Journey
  1. Based off the 8 sample customers provided in the sample from the subscriptions table, write a brief description about each customer’s onboarding journey. Try to keep it as short as possible - you may also want to run some sort of join to make your explanations a bit easier!
B. Data Analysis Questions
  1. How many customers has Foodie-Fi ever had?
  2. What is the monthly distribution of trial plan start_date values for our dataset - use the start of the month as the group by value
  3. What plan start_date values occur after the year 2020 for our dataset? Show the breakdown by count of events for each plan_name.
  4. What is the customer count and percentage of customers who have churned rounded to 1 decimal place?
  5. How many customers have churned straight after their initial free trial - what percentage is this rounded to the nearest whole number?
  6. What is the number and percentage of customer plans after their initial free trial?
  7. What is the customer count and percentage breakdown of all 5 plan_name values at 2020-12-31?
  8. How many customers have upgraded to an annual plan in 2020?
  9. How many days on average does it take for a customer to an annual plan from the day they join Foodie-Fi?
  10. Can you further breakdown this average value into 30 day periods (i.e. 0-30 days, 31-60 days etc)
  11. How many customers downgraded from a pro monthly to a basic monthly plan in 2020?
C. Challenge Payment Question
  1. The Foodie-Fi team wants you to create a new payments table for the year 2020 that includes amounts paid by each customer in the subscriptions table with the following requirements:
    • monthly payments always occur on the same day of month as the original start_date of any monthly paid plan;
    • upgrades from basic to monthly or pro plans are reduced by the current paid amount in that month and start immediately;
    • upgrades from pro monthly to pro annual are paid at the end of the current billing period and also starts at the end of the month period;
    • once a customer churns they will no longer make payments.
D. Outside The Box Questions
  1. How would you calculate the rate of growth for Foodie-Fi?
  2. What key metrics would you recommend Foodie-Fi management to track over time to assess performance of their overall business?
  3. What are some key customer journeys or experiences that you would analyse further to improve customer retention?
  4. If the Foodie-Fi team were to create an exit survey shown to customers who wish to cancel their subscription, what questions would you include in the survey?
  5. What business levers could the Foodie-Fi team use to reduce the customer churn rate? How would you validate the effectiveness of your ideas?

🚧 Other cases will be added in the future 🚧

Releases

No releases published

Packages

No packages published

Languages