An end-to-end SQL analysis of pizza sales data to uncover revenue trends, top-performing products, and peak ordering patterns using MySQL.
This project analyzes a pizza restaurant's transactional data to answer key business questions around sales performance, product popularity, and customer ordering behavior. All insights are derived purely through SQL queries — from basic aggregations to advanced window functions and CTEs.
| Metric | Finding |
|---|---|
| Total Records Analyzed | 10,000+ orders |
| Top Revenue Categories | Top 3 drove 65%+ of total revenue |
| Peak Ordering Time | Friday evenings = 22% of weekly orders |
| Query Techniques Used | CTEs, Window Functions, JOINs, Subqueries |
- Tables: orders, order_details, pizzas, pizza_types
- Key Fields: order_id, pizza_id, quantity, price, category, order_date, order_time
- Source: Pizza Hut sales dataset (included in repo)
- Total number of orders placed
- Total revenue generated from pizza sales
- Highest-priced pizza identification
- Most common pizza size ordered
- Top 5 most ordered pizza types by quantity
- Category-wise distribution of pizzas
- Distribution of orders by hour of the day
- Average number of pizzas ordered per day
- Cumulative revenue generated over time
- Top 3 most ordered pizza types by revenue
- Percentage contribution of each pizza type to total revenue
- Top 3 pizza types by revenue within each category (using window functions)
- 🏆 Top 3 pizza categories drove 65%+ of total revenue — focus marketing here
- ⏰ Friday evenings account for 22% of weekly orders — optimize staffing and prep
- 📏 Large size was the most ordered — upsell opportunity for XL
- 💰 Classic pizzas consistently outperform specialty in volume
Pizza-Sales-Analysis-SQL-Project/
│
├── Pizza Sales Source Code.sql # All SQL queries (basic → advanced)
├── Pizza Sales Analysis SQL Project.pdf # Full analysis report with results
├── Reference File for pizza sales analysis.txt # Query reference guide
├── order_details.csv # Order line items data
├── orders.csv # Order header data
├── pizza_types.csv # Pizza catalog data
└── README.md
-
Install MySQL Workbench (free download at mysql.com)
-
Create the database:
CREATE DATABASE pizzahut;
USE pizzahut;-
Import the CSV files as tables (order_details, orders, pizzas, pizza_types)
-
Open
Pizza Sales Source Code.sqland run queries section by section
-- Example: Top 3 pizza types by revenue per category (Window Function)
SELECT category, name, revenue,
RANK() OVER (PARTITION BY category ORDER BY revenue DESC) AS rnk
FROM (
SELECT pt.category, pt.name,
SUM(od.quantity * p.price) AS revenue
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_pizzas;- Writing complex SQL queries using CTEs, window functions, and multi-table JOINs
- Translating business questions into structured SQL queries
- Using revenue contribution % to prioritize product decisions
- Identifying operational patterns (peak hours) to drive staffing recommendations
