MySQL MySQL Workbench 13 Business Queries Completed ✓
🍕

Pizza Sales
Data Analysis

Transforming raw pizza sales data into crisp, actionable business intelligence — one query at a time.

View SQL File ↗ LinkedIn Showcase
Explore the Analysis

Project Metrics

Core numbers from the dataset powering this analysis.

Total Revenue
$817,860
Total Orders
21,350
Pizzas Sold
49,574
Business Queries
13

Dataset Schema

Four relational tables connected across order, detail, pizza, and type dimensions.

📋 orders
order_idPK
dateDATE
timeTIME
📄 order_details
order_details_idPK
order_idFK
pizza_idFK
quantityINT
🍕 pizzas
pizza_idPK
pizza_type_idFK
sizeVARCHAR
priceDECIMAL
📂 pizza_types
pizza_type_idPK
nameVARCHAR
categoryVARCHAR
ingredientsTEXT

orders ─── 1:N ───> order_details | order_details ─── N:1 ───> pizzas | pizzas ─── N:1 ───> pizza_types

Analysis Modules

13 queries organized across four analytical pillars.

01
Revenue & Pricing Analysis
#Business QuestionSQL Technique
Q1Total revenue generatedSUM(price × quantity)
Q2Highest-priced pizzaORDER BY price DESC LIMIT 1
Q3Average order valueTotal revenue ÷ COUNT(orders)
Outcome: Established a revenue baseline of $817,860 and identified the premium product tier (The Greek Pizza at $35.95).
02
Customer & Order Trends
#Business QuestionSQL Technique
Q4Total number of orders placedCOUNT(DISTINCT order_id)
Q5Most preferred pizza sizeGROUP BY size ORDER BY COUNT
Q6Peak ordering hoursHOUR(time) extraction & GROUP BY
Outcome: Pinpointed 12–1 PM (lunch) and 6–8 PM (dinner) as peak demand windows. Large is the most ordered size.
03
Top Performer Rankings
#Business QuestionSQL Technique
Q7Top 5 pizzas by quantity soldSUM(quantity) GROUP BY + LIMIT 5
Q8Sales distribution by categoryGROUP BY category with % share
Q9Category generating most revenueRevenue aggregated per category
Outcome: Classic category dominates at 26.91% of total revenue. Classic Deluxe leads quantity sold.
04
Advanced Business Intelligence
#Business QuestionSQL Technique
Q10Cumulative revenue growth over timeSUM() OVER (ORDER BY date)
Q11Average daily order volumeCTE → AVG of daily counts
Q12Top 3 pizzas within each categoryRANK() OVER (PARTITION BY category)
Q13Revenue % per categorySubquery for total ÷ category revenue
Outcome: Rolling revenue curves reveal sustained growth. RANK() OVER PARTITION exposes category-level leaders for targeted promotions.

Query Samples

Key queries demonstrating advanced SQL concepts used across all four modules.

cumulative_revenue.sql
-- Q10: Cumulative revenue growth over time (Rolling Window)
SELECT
    date,
    SUM(revenue) OVER (
        ORDER BY date
    ) AS cumulative_revenue
FROM (
    SELECT
        o.date,
        SUM(od.quantity * p.price) AS revenue
    FROM orders o
    JOIN order_details od  ON o.order_id  = od.order_id
    JOIN pizzas p          ON od.pizza_id = p.pizza_id
    GROUP BY o.date
) daily_revenue
ORDER BY date;
avg_daily_orders.sql
-- Q11: Average daily order volume using CTE
WITH daily_orders AS (
    SELECT
        date,
        COUNT(order_id) AS total_orders
    FROM orders
    GROUP BY date
)
SELECT
    ROUND(AVG(total_orders), 2) AS avg_orders_per_day
FROM daily_orders;
rank_by_category.sql
-- Q12: Top 3 pizzas within each category using RANK()
SELECT
    category,
    name,
    quantity,
    rnk
FROM (
    SELECT
        pt.category,
        pt.name,
        SUM(od.quantity) AS quantity,
        RANK() OVER (
            PARTITION BY pt.category
            ORDER BY SUM(od.quantity) DESC
        ) AS rnk
    FROM pizza_types pt
    JOIN pizzas p      ON pt.pizza_type_id = p.pizza_type_id
    JOIN order_details od ON p.pizza_id = od.pizza_id
    GROUP BY pt.category, pt.name
) ranked
WHERE rnk <= 3
ORDER BY category, rnk;

Executive Summary

Findings distilled from all 13 queries across the full dataset.

Revenue by Category

Classic26.91%
Supreme25.46%
Chicken23.96%
Veggie23.68%

Top 5 Revenue Leaders

  • 1Classic Deluxe Pizza
  • 2Barbecue Chicken Pizza
  • 3Hawaiian Pizza
  • 4Pepperoni Pizza
  • 5Thai Chicken Pizza

Peak Demand Windows

12–1 PM
Lunch Rush
6–8 PM
Dinner Wave

Staffing and promotional campaigns should prioritize these two daily windows.

Order Volume by Size

Large (L)
45%
Medium (M)
30%
Small (S)
21%
XL / XXL
4%

Project Structure

📁 Pizza_sale--Sql /
📄
Pizza_sales_analysis.sql

All 13 business logic queries — labelled by question for easy navigation.

📝
README.md

Project documentation, schema diagram, insights summary, and setup guide.

Get Started Locally

Clone the repository — git clone https://github.com/pritwrk9-ux/Pizza_sale--Sql.git
Open MySQL Workbench and connect to your local MySQL server.
Import the four dataset tables — orders, order_details, pizzas, pizza_types.
Open Pizza_sales_analysis.sql and run queries individually or all at once. Each is labelled with its business question.