Skip to content

πŸ“Š End-to-end SQL data analysis project on pizza sales using PostgreSQL. πŸ› οΈ SQL | PostgreSQL | Data Cleaning | Aggregations | CTEs | Window Functions

Notifications You must be signed in to change notification settings

Harsh-Belekar/Pizza-Sales-SQL-Analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ• Pizza Sales SQL Analysis

This project demonstrates my ability to perform end-to-end SQL data analysis on real-world sales data.
Using PostgreSQL, I designed the database schema, imported raw CSV files, and wrote queries to answer business-driven questions ranging from simple sales reporting to advanced insights using CTEs, subqueries, and window functions.

The analysis highlights not just technical SQL skills but also the ability to extract actionable business insights β€” the kind of analysis companies use to understand sales performance, customer behavior, and revenue drivers.


πŸ“‚ Project Structure

  • create_table_query.txt β†’ SQL schema for creating tables
  • Pizza_sales_csv.zip β†’ Dataset (Orders, Order Details, Pizzas, Pizza Types)
  • Questions.txt β†’ 30+ SQL questions (Basic β†’ Advanced)
  • Answer.sql β†’ My SQL solutions with business insights
  • images β†’ Sample Output & Schema Diagram Screenshot images

πŸ—‚οΈ Database Schema

The database is designed with four tables: pizzas, pizza_types, orders, and order_details.
This schema ensures normalized relationships between orders, pizzas, and pizza categories.

Database Schema
Figure: Entity-Relationship (ER) diagram of the Pizza Sales database schema


πŸ› οΈ Tech Stack

  • PostgreSQL
  • SQL
  • CSV (raw dataset)
  • GitHub for version control
  • Data Analysis & Business Insights
  • Markdown (Documentation)

πŸ› οΈ Skills & SQL Techniques

  • βœ”οΈ Data Cleaning & Schema Design
  • βœ”οΈ Joins (INNER, LEFT)
  • βœ”οΈ Aggregations (SUM, COUNT, AVG, GROUP BY, HAVING)
  • βœ”οΈ Date & Time Functions (sales by hour, day, month)
  • βœ”οΈ Subqueries & Nested Queries
  • βœ”οΈ Common Table Expressions (CTEs)
  • βœ”οΈ Window Functions (RANK, ROW_NUMBER, DENSE_RANK)

πŸ“Š Key Business Insights

  • πŸ•‘ Peak Sales Hours β†’ Highest orders between 12 PM – 1 PM (lunch time)
  • πŸ• Top-Selling Pizzas β†’ Classic Deluxe and Hawaiian lead sales volume
  • πŸ’° Revenue Contribution β†’ Large-size pizzas generate the most revenue
  • πŸ“ˆ Monthly Trends β†’ Sales peak on weekends and month-end
  • πŸ‘₯ Customer Patterns β†’ Some customers repeatedly placed 10+ orders

πŸš€ How to Reproduce

  1. Run create_table_query.txt to create the database schema
  2. Import CSVs from Pizza_sales_csv.zip into PostgreSQL
  3. Solve questions from Questions.txt
  4. Compare results with Answer.sql

πŸ† What I Achieved

  • Built a sales analytics project from raw transactional data
  • Extracted business insights that could help optimize sales & strategy
  • Demonstrated SQL expertise in schema design, joins, aggregations, CTEs & window functions
  • Practiced real-world analytics similar to what companies expect from data analysts

πŸ“Έ Sample Output

Top 3 Pizzas
Figure: Top 3 pizzas in each Category by revenue contribution

Query

--4.Identify the top 3 pizza types contributing the most to revenue in each category.
WITH ranked_pizzas AS (
	SELECT pt.category, pt.name,
	SUM(p.price * od.quantity) AS total_revenue,
	ROW_NUMBER() OVER (PARTITION BY pt.category 
		ORDER BY SUM(p.price * od.quantity) DESC) AS rank_within_category
	FROM order_details od
	JOIN pizzas p ON od.pizza_id = p.pizza_id
	JOIN pizza_types pt ON p.pizza_type_id = pt.pizza_type_id
	GROUP BY pt.category, pt.name
)
SELECT rp.category, rp.name, rp.total_revenue
FROM ranked_pizzas rp
WHERE rp.rank_within_category <= 3;

πŸ“§ Contact

πŸ”— LinkedIn – Harsh Belekar

About

πŸ“Š End-to-end SQL data analysis project on pizza sales using PostgreSQL. πŸ› οΈ SQL | PostgreSQL | Data Cleaning | Aggregations | CTEs | Window Functions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published