farincyntiya / SQL-practices

The datasets, codes, and other files used and produced in learning MySQL & PostgreSQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL Practices

This is a repository where I stored my SQL query practices using MySQL and PostgreSQL

Special thanks to Data with Danny for the SQL case studies! โœจ

I used MySQL Workbench and PostgreSQL to solve the case studies ๐Ÿ’ป

The SQL challenge by Danny can be found on the website #8WeekSQLChallenge


๐Ÿ“š Table of Contents ๐Ÿ“š


Case Study #1: Danny's Diner

Danny's Diner

Danny's Diner SQL Case Study can be found here

The Case:

Danny seriously loves Japanese food so, at the beginning of 2021, he decides to embark upon a risky venture and opens up a cute little restaurant that sells his 3 favorite foods: sushi, curry, and ramen. Dannyโ€™s Diner is in need of assistance to help the restaurant stay afloat - the restaurant has captured some very basic data from their few months of operation but has no idea how to use their data to help them run the business.

The Entity Relationship Diagram:

Danny's Diner ERD

The ERD of Danny's Diner case study can be inspected here

Case Study Questions:

๐Ÿ“Ž Click here to expand
  1. What is the total amount each customer spent at the restaurant?
  2. How many days have 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 customers A and B have at the end of January?

Case Study #2: Pizza Runner

Pizza Runner

Pizza Runner SQL Case Study can be found here

The Case:

Danny was scrolling through his Instagram feed when something really caught his eye - โ€œ80s Retro Styling and Pizza Is The Future!โ€ Danny was sold on the idea, but he knew that pizza alone was not going to help him get seed funding to expand his new Pizza Empire - so he had one more genius idea to combine with it - he was going to Uberize it - and so Pizza Runner was launched! Danny started by recruiting โ€œrunnersโ€ to deliver fresh pizza from Pizza Runner Headquarters (otherwise known as Dannyโ€™s house) and also maxed out his credit card to pay freelance developers to build a mobile app to accept orders from customers.

The Entity Relationship Diagram:

Pizza Runner ERD

The ERD of Pizza Runner case study can be inspected here

Case Study Questions:

๐Ÿ“Ž Click here to expand
  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?

Superstore Case Study

Superstore

The Case:

As one of the Business Intelligence Analysts in the Superstore, you are asked to support analysis needs, both from the internal BI team itself and from other teams such as Marketing, Business Development, Sales, etc.

Case Study Questions:

๐Ÿ“Ž Click here to expand
  1. How many orders on the SAME DAY had delivery delays?
  2. How was the relationship between the amount of discount given and the profitability received by the company?
  3. What were the average discount and profits for each subcategory in the categories?
  4. What were the total sales and average profit for California, Texas, and Georgia from each customer segment in 2016?
  5. What were the total customers who had an average discount above 0.4 for each region?

About

The datasets, codes, and other files used and produced in learning MySQL & PostgreSQL