In this project, I analyzed a pizza sales dataset using SQL to understand sales performance, customer ordering behavior, and product-level trends. The goal was to extract meaningful insights that can help optimize revenue, identify top-selling pizzas, and improve business decision-making.
TOOLS USED:
MySQL
SQL Queries: Joins, Aggregate Functions, Date Functions
Database Table: pizza_sales.
KPIs calculated from SQL
Cleaned and explored the sales dataset
Calculated key business metrics (KPIs)
Analyzed daily & hourly order trends
Identified top-performing pizza categories and sizes
Found best & worst selling pizzas
Generated insights for inventory and revenue optimization
Used SQL date functions (MONTH, QUARTER, HOUR) for trend analysis
SOME SQL QUERIES:[BASICS]
SELECT SUM(total_price) AS Total_Revenue FROM pizza_sales;
SELECT (SUM(total_price) / COUNT(DISTINCT order_id)) AS Avg_order_Value FROM pizza_sales;
SELECT SUM(quantity) AS Total_pizza_sold FROM pizza_sales;
SELECT COUNT(DISTINCT order_id) AS Total_Orders FROM pizza_sales;
SELECT CAST(CAST(SUM(quantity) AS DECIMAL(10,2))/
CAST(COUNT(DISTINCT order_id) AS DECIMAL(10,2)) AS DECIMAL(10,2))
AS Avg_Pizzas_per_order
FROM pizza_sales;
SELECT DATENAME(DW, order_date) AS order_day,
COUNT(DISTINCT order_id) AS total_orders
FROM pizza_sales
GROUP BY DATENAME(DW, order_date);
SELECT DATEPART(HOUR, order_time) as order_hours,
COUNT(DISTINCT order_id) as total_orders
FROM pizza_sales
GROUP BY DATEPART(HOUR, order_time)
ORDER BY DATEPART(HOUR, order_time);
SELECT pizza_category,
CAST(SUM(total_price) AS DECIMAL(10,2)) as total_revenue,
CAST(SUM(total_price) * 100 /
(SELECT SUM(total_price) from pizza_sales) AS DECIMAL(10,2)) AS PCT
FROM pizza_sales
GROUP BY pizza_category;
Peak Ordering Times: Daily and hourly trends showed which days and times customers order the most. This helps understand demand patterns and staff scheduling needs.
Category-wise Revenue Contribution: Some pizza categories contributed a higher share of total revenue, helping identify customer preferences and menu strengths.
Pizza Size Performance: Analyzing sales by size revealed which pizza sizes customers preferred, useful for pricing and inventory planning.
Best & Worst Sellers: Top 5 and bottom 5 pizzas were identified using SQL aggregations, showing which products drive sales and which may need discontinuation or improvements.
This SQL project helped me understand how raw sales data can be transformed into actionable insights. By analyzing KPIs, ordering trends, and product performance using SQL queries, I gained deeper clarity into the business's strengths and improvement areas. This approach can be applied to any retail or food-service business to support data-driven decision-making.