Danny's Diner

stylized icon image of bowl and chopsticks holding noodles in black with the words Danny's Diner on a pink background.


Feeling confident with Basic SQL, I wanted to upskill and learn window functions. I completed this case study using a project created by Data Analyst, Danny Ma.

To Data with Danny Case Study

Problem Statement

Danny wants to use the data to answer a few simple questions about his customers, especially about their visiting patterns, how much money they’ve spent and also which menu items are their favourite. Having this deeper connection with his customers will help him deliver a better and more personalised experience for his loyal customers.

He plans on using these insights to help him decide whether he should expand the existing customer loyalty program - additionally he needs help to generate some basic datasets so his team can easily inspect the data without needing to use SQL.

Data Exploration

Danny has shared with you 3 key datasets for this case study:

  • sales
  • menu
  • members

The following questions were proposed for data exploration:

  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?


Key Learning

From time to time, I would get stuck and reference YouTube video solutions. With question 10, I wasn't happy with the suggested solutions I was finding.

Since the data set was small, I got out a pen and paper to figure out the totals I should be getting. The proposed solution was off.

After some experimenting, I found that the Interval function was not operating correctly in a RANK() function, so the proper dates weren't being filtered.

I found the solution to create a date window for the filtering and was finally able to match my pen and paper solution.

I learned that it's key to trust your instincts. And it doesn't hurt to double check your work manually, if you can.

Bonus Questions

The following questions are related creating basic data tables that Danny and his team can use to quickly derive insights without needing to join the underlying tables using SQL.

Recreate the following tables output using the available data:

Thanks for Reading!