- Notifications
You must be signed in to change notification settings - Fork0
MoaviaMahmood/Data-analysis-with-SQL-Pizza-Sales
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This repository contains SQL queries to perform data analysis on pizza sales data. The analysis covers various aspects such as order quantities, revenue, pizza preferences, and temporal patterns.
SELECTCOUNT(order_id)AS Total_OrdersFROM orders;
- Total Revenue Generated from Pizza Sales
SELECT ROUND(SUM(orders_details.quantity*pizzas.price),2)AS Total_SalesFROM orders_detailsJOIN pizzasONpizzas.pizza_id=orders_details.pizza_id;
- Highest-Priced Pizza
SELECTpizza_types.name,pizzas.priceFROM pizza_typesJOIN pizzasONpizza_types.pizza_type_id=pizzas.pizza_type_idORDER BYpizzas.priceDESCLIMIT1;
- Count of Pizza Size Ordered
selectpizzas.size,count(orders_details.order_details_id)AS orders_countfrom pizzasjoin orders_detailsonpizzas.pizza_id=orders_details.pizza_idgroup bypizzas.sizeorder by orders_countdesc;
- Top 5 Most Ordered Pizza Types along with Their Quantities
SELECTpizza_types.name,sum(orders_details.quantity)as quantityfrom pizza_typesjoin pizzasonpizza_types.pizza_type_id=pizzas.pizza_type_idjoin orders_detailsonorders_details.pizza_id=pizzas.pizza_idgroup bypizza_types.nameorder by quantitydesclimit5;
- Total Quantity of Each Pizza Category Ordered
SELECTpizza_types.category,SUM(orders_details.quantity)AS quantityFROM pizza_typesJOIN pizzasONpizza_types.pizza_type_id=pizzas.pizza_type_idJOIN orders_detailsONorders_details.pizza_id=pizzas.pizza_idGROUP BY pizza_types.
- Distribution of Orders by Hour of the Day
SELECT DATEPART(HOUR, order_time)as hours,COUNT(order_id)AS ORDERSFROM ordersGROUP BY DATEPART(HOUR, order_time)order by hours;
- Category-wise Distribution of Pizzas
SELECT category,COUNT(name)as totalFROM pizza_typesgroup by category;
- Average Number of Pizzas Ordered per Day
SELECT ROUND(AVG(quantity),0)AS average_order_quantityFROM (SELECTorders.order_dateASdate,SUM(orders_details.quantity)AS quantityFROM ordersJOIN orders_detailsONorders.order_id=orders_details.order_idGROUP BYdate)AS order_quantity;
- Top 3 Most Ordered Pizza Types Based on Revenue
SELECTpt.nameAS names, ROUND(SUM(od.quantity*p.price),0)AS revenueFROM pizza_types ptJOIN pizzas pONp.pizza_type_id=pt.pizza_type_idJOIN orders_details odONod.pizza_id=p.pizza_idGROUP BYpt.nameORDER BY revenueDESCOFFSET0 ROWS FETCH NEXT3 ROWS ONLY;
- Percentage Contribution of Each Pizza Type to Total Revenue
SELECTpizza_types.category, ROUND((SUM(orders_details.quantity*pizzas.price)/ (SELECT ROUND(SUM(orders_details.quantity*pizzas.price),2)AS total_salesFROM orders_detailsJOIN pizzasONpizzas.pizza_id=orders_details.pizza_id))*100,2)AS revenueFROM pizza_typesJOIN pizzasONpizza_types.pizza_type_id=pizzas.pizza_type_idJOIN orders_detailsONorders_details.pizza_id=pizzas.pizza_idGROUP BYpizza_types.categoryORDER BY revenueDESC;
- Cumulative Revenue Generated Over Time
select order_date,sum(revenue) over(order by order_date)as cuml_revenuefrom (selectorders.order_date, round(sum(orders_details.quantity*pizzas.price),0)as revenuefrom orders_detailsjoin pizzasonorders_details.pizza_id=pizzas.pizza_idjoin ordersonorders.order_id=orders_details.order_idgroup byorders.order_date)as sales;
- Top 3 Most Ordered Pizza Types Based on Revenue for Each Pizza Category
SELECT name,revenueFROM (SELECT category, name, revenue, RANK() OVER(PARTITION BY categoryORDER BY revenuedesc)as rnFROM (SELECTpizza_types.category,pizza_types.name,SUM(orders_details.quantity*pizzas.price)AS revenueFROM pizza_typesJOIN pizzasONpizza_types.pizza_type_id=pizzas.pizza_type_idJOIN orders_detailsONorders_details.pizza_id=pizzas.pizza_idGROUP BYpizza_types.category ,pizza_types.name )as a )as b;
About
A data analysis project using SQL to explore and analyze pizza sales data, including insights on sales trends, customer preferences, and branch performance.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published