{"id":23511113,"url":"https://github.com/iankitnegi/sql_pizza_sales_project","last_synced_at":"2025-07-21T09:33:19.530Z","repository":{"id":245542387,"uuid":"818558313","full_name":"iankitnegi/SQL_Pizza_Sales_Project","owner":"iankitnegi","description":"As a BI Consultant for Plato's Pizza, you'll analyze a year's worth of transactional data to identify opportunities for driving sales and improving operational efficiency, helping the restaurant enhance its performance.","archived":false,"fork":false,"pushed_at":"2024-06-22T07:53:46.000Z","size":843,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-13T17:19:30.925Z","etag":null,"topics":["mysql","sales","sql"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iankitnegi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-22T07:02:47.000Z","updated_at":"2024-06-22T13:47:01.000Z","dependencies_parsed_at":"2024-06-22T17:47:36.985Z","dependency_job_id":"f3c84840-146b-4394-8415-ba77a378a0a5","html_url":"https://github.com/iankitnegi/SQL_Pizza_Sales_Project","commit_stats":null,"previous_names":["iankitnegi/sql_pizza_sales_project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iankitnegi/SQL_Pizza_Sales_Project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_Pizza_Sales_Project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_Pizza_Sales_Project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_Pizza_Sales_Project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_Pizza_Sales_Project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iankitnegi","download_url":"https://codeload.github.com/iankitnegi/SQL_Pizza_Sales_Project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iankitnegi%2FSQL_Pizza_Sales_Project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266276128,"owners_count":23903981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mysql","sales","sql"],"created_at":"2024-12-25T12:13:20.900Z","updated_at":"2025-07-21T09:33:19.513Z","avatar_url":"https://github.com/iankitnegi.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Problem Statement  \nThe objective of this analysis is to evaluate a year's worth of sales data from a fictitious pizza place to identify opportunities to drive more sales and improve operational efficiency. The analysis will focus on understanding sales patterns, customer preferences, and operational bottlenecks.\n\n\n\n## 1. ASK  \nStakeholder: Maven (Manager)  \n\n### Questions:  \n- How many customers do we have each day? Are there any peak hours?\n- How many pizzas are typically in an order? Do we have any bestsellers?\n- How much money did we make this year? Can we indentify any seasonality in the sales?\n- Are there any pizzas we should take of the menu, or any promotions we could leverage?\n\n\n\n## 2. PREPARE  \n### Data Storage:  \nThe public dataset is completely available on the Maven Analytics website platform where it stores and consolidates all available datasets for analysis in the Data Playground. The specific individual datasets at hand can be obtained at this link below: https://www.mavenanalytics.io/blog/maven-pizza-challenge\n\n### Data Organized:  \nThis Pizza Restaurant Sales dataset uploaded by Shi Long Zhuang was downloaded from Kaggle.  \nThis dataset contains 4 file. It is saved on the computer in the Pizza Sales folder.\n\n\n\n## 3. PROCESS\n### Tools Used:  \n- MySQL\n- MS-Word\n\n### Data Used:\norder_details, orders, pizza_types, pizzas\n\n### About Data:  \nThis dataset contains a year's worth of sales data from a fictitious pizza place, including details on orders, pizzas, and their types. The dataset is structured across several tables, each with specific fields that describe various aspects of the sales transactions.\n\n## Table Descriptions\n\n#### Orders Table\n| Field    | Description                                                       |\n|----------|-------------------------------------------------------------------|\n| order_id | Unique identifier for each order placed                           |\n| date     | Date the order was placed (entered into the system prior to cooking \u0026 serving) |\n| time     | Time the order was placed (entered into the system prior to cooking \u0026 serving) |\n\n#### Order Details Table\n| Field             | Description                                                                 |\n|-------------------|-----------------------------------------------------------------------------|\n| order_details_id  | Unique identifier for each pizza placed within each order                   |\n| order_id          | Foreign key that ties the details in each order to the order itself         |\n| pizza_id          | Foreign key that ties the pizza ordered to its details, like size and price |\n| quantity          | Quantity ordered for each pizza of the same type and size                   |\n\n#### Pizzas Table\n| Field         | Description                             |\n|---------------|-----------------------------------------|\n| pizza_id      | Unique identifier for each pizza        |\n| pizza_type_id | Foreign key that ties each pizza to its broader pizza type |\n| size          | Size of the pizza (Small, Medium, Large, X Large, or XX Large) |\n| price         | Price of the pizza in USD               |\n\n#### Pizza Types Table\n| Field         | Description                                                         |\n|---------------|---------------------------------------------------------------------|\n| pizza_type_id | Unique identifier for each pizza type                               |\n| name          | Name of the pizza as shown in the menu                              |\n| category      | Category that the pizza falls under in the menu (Classic, Chicken, Supreme, or Veggie) |\n| ingredients   | Comma-delimited ingredients used in the pizza as shown in the menu (they all include Mozzarella Cheese, even if not specified; and they all include Tomato Sauce, unless another sauce is specified) |\n\n## Summary of Data Relationships\n\n- **Orders** table contains high-level details of each order.\n- **Order Details** table provides specific information about each pizza included in an order.\n- **Pizzas** table lists individual pizzas with details about their size and price.\n- **Pizza Types** table categorizes pizzas and lists their ingredients.\n\n### Data Cleaning \u0026 Transformation\n- Duplicates were checked with the Remove Duplicates function.\n- Gaps were checked with the TRIM function.\n- Pizza sizes represented as S, M, L, X, XL, XXL in the pizza_size column were changed to Small, Medium, Large, XLarge, XXLarge with the Find \u0026 Replace function.\n- Blank and NULL checked for all columns with filter function.\n- Saved as a pizza_sales.csv\n\n\n\n## 4. ANALYZE  \nData Analyzing  \nMicrosoft SQL was used to analyze data.  \n\n-- KPI’s REQUIREMENT --  \n#1 Retrieve the total number of orders placed.  \nSELECT COUNT(*) AS total_orders  \nFROM orders;  \n    \n#2 Calculate the total revenue generated from pizza sales.  \nSELECT ROUND(SUM(price * quantity), 2) AS rev  \nFROM order_details o  \nJOIN pizzas p   \nON o.pizza_id = p.pizza_id;  \n\n#3 Identify the highest-priced pizza.  \nSELECT name, price  \nFROM pizzas p  \nJOIN pizza_types t  \nON p.pizza_type_id=t.pizza_type_id  \nORDER BY price DESC  \nLIMIT 1;  \n\n#4 Identify the most common pizza size ordered.  \nSELECT size, COUNT(*) AS cnt  \nFROM order_details o  \nJOIN pizzas p  \nON o.pizza_id=p.pizza_id  \nGROUP BY size  \nORDER BY cnt DESC;  \n\n#5 List the top 5 most ordered pizza types along with their quantities.  \nWITH cte1 AS(  \nSELECT pt.name, SUM(o.quantity) AS qty  \nFROM pizza_types pt  \nJOIN pizzas p  \nON pt.pizza_type_id=p.pizza_type_id  \nJOIN order_details o  \nON p.pizza_id=o.pizza_id  \nGROUP by pt.name)  \nSELECT * FROM cte1  \nORDER BY qty DESC  \nLIMIT 5;  \n\n#6 Join the necessary tables to find the total quantity of each pizza category ordered  \nSELECT pt.category, SUM(o.quantity) AS qty  \nFROM pizza_types pt  \nJOIN pizzas p  \nON pt.pizza_type_id=p.pizza_type_id  \nJOIN order_details o  \nON p.pizza_id=o.pizza_id  \nGROUP BY category  \nORDER BY qty DESC;  \n\n#7 Determine the distribution of orders by hour of the day.  \nSELECT HOUR(order_time) AS hrs, COUNT(order_id) AS order_cnt  \nFROM orders  \nGROUP BY hrs  \nORDER BY order_cnt DESC;  \n\n#8 Join relevant tables to find the category-wise distribution of pizzas.  \nSELECT category, COUNT(*) AS pizza_type  \nFROM pizza_types  \nGROUP BY category;  \n\n#9 Group the orders by date and calculate the average number of pizzas ordered per day.  \nWITH cte1 AS(  \nSELECT DATE(order_date) AS order_date, SUM(od.quantity) AS pizza  \nFROM orders o  \nJOIN order_details od  \nON o.order_id=od.order_id  \nGROUP BY order_date)  \nSELECT ROUND(AVG(pizza)) AS avg_pizza_order_per_day  \nFROM cte1;  \n\n#10 Determine the top 3 most ordered pizza types based on revenue.  \nSELECT pt.name, SUM((p.price*od.quantity)) AS rev  \nFROM pizza_types pt  \nJOIN pizzas p  \nON pt.pizza_type_id=p.pizza_type_id  \nJOIN order_details od  \nON p.pizza_id=od.pizza_id  \nGROUP BY pt.name  \nORDER BY rev DESC  \nLIMIT 3;  \n\n#11 Calculate the percentage contribution of each pizza type to total revenue.  \nWITH cte1 AS(  \nSELECT pt.category, ROUND(SUM(p.price* o.quantity)) AS rev  \nFROM pizza_types pt  \nJOIN pizzas p  \nON pt.pizza_type_id=p.pizza_type_id  \nJOIN order_details o  \nON o.pizza_id=p.pizza_id  \nGROUP BY pt.category),  \ncte2 AS(  \nSELECT category, rev*100/SUM(rev) OVER() AS pct_decimal  \nFROM cte1)  \nSELECT category, ROUND(pct_decimal,2) AS pct  \nFROM cte2;  \n\n#12 Analyze the cumulative revenue generated over time.  \nWITH cte1 AS(  \nSELECT DATE(o.order_date) AS o_date, ROUND(SUM(od.quantity*p.price),2) AS rev  \nFROM orders o  \nJOIN order_details od  \nON o.order_id=od.order_id  \nJOIN pizzas p  \nON od.pizza_id=p.pizza_id  \nGROUP BY o_date)  \nSELECT o_date AS order_date, SUM(rev) OVER(ORDER BY o_date) AS cummulative_rev  \nFROM cte1;  \n\n#13 Determine the top 3 most ordered pizza types based on revenue for each pizza category.  \nWITH cte1 AS(  \nSELECT pt.category, pt.name, SUM(p.price*o.quantity) AS rev  \nFROM pizza_types pt  \nJOIN pizzas p  \nON pt.pizza_type_id=p.pizza_type_id  \nJOIN order_details o  \nON o.pizza_id=p.pizza_id  \nGROUP BY pt.category, pt.name  \n),  \ncte2 AS(  \nSELECT *, RANK() OVER(PARTITION BY category ORDER BY rev DESC) AS rn  \nFROM cte1)  \nSELECT * FROM cte2  \nWHERE rn\u003c=3;  \n\n\n\n## 5. SHARE\n![Screenshot (132)](https://github.com/iankitnegi/SQL_Pizza_Sales_Project/assets/132642567/e4057bd4-66fb-4e56-b02f-f1fedecc9c70)\n![Screenshot (133)](https://github.com/iankitnegi/SQL_Pizza_Sales_Project/assets/132642567/8dded99a-74f7-4c3f-8ab5-5e2d5ccc4f16)\n\n\n\n## 6. ACT  \n### Insights:\n- Top-selling Pizzas: Classic Deluxe and Barbecue Chicken Pizza dominated the charts!\n- Peak Hours: Evenings from 12:00-19:00 has the highest sales volumes.\n- Customer Behavior: Large pizzas were more popular among group orders.\n\n### Recommendations:\n- Sales can be increased with a campaign on Sundays and Mondays, when pizza sales are lowest.\n- Supreme and Veggie categories are the pizza categories with the worst sales, and XLarge and XXLarge sizes are the least sold pizza sizes. These categories and sizes can be evaluated in campaigns.  \n\nThank you for reading and evaluating my repo :)    \n[LinkedIn](https://www.linkedin.com/posts/iankitnegi_sales-report-activity-7198593703102353408-GrAW?utm_source=share\u0026utm_medium=member_desktop)    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiankitnegi%2Fsql_pizza_sales_project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiankitnegi%2Fsql_pizza_sales_project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiankitnegi%2Fsql_pizza_sales_project/lists"}