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.
create_table_query.txt
β SQL schema for creating tablesPizza_sales_csv.zip
β Dataset (Orders, Order Details, Pizzas, Pizza Types)Questions.txt
β 30+ SQL questions (Basic β Advanced)Answer.sql
β My SQL solutions with business insightsimages
β Sample Output & Schema Diagram Screenshot images
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.
Figure: Entity-Relationship (ER) diagram of the Pizza Sales database schema
- PostgreSQL
- SQL
- CSV (raw dataset)
- GitHub for version control
- Data Analysis & Business Insights
- Markdown (Documentation)
- βοΈ 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)
- π 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
- Run
create_table_query.txt
to create the database schema - Import CSVs from
Pizza_sales_csv.zip
into PostgreSQL - Solve questions from
Questions.txt
- Compare results with
Answer.sql
- 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
Figure: Top 3 pizzas in each Category by revenue contribution
--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;