0% found this document useful (0 votes)
5 views

SQL Queries

Uploaded by

ravichandu010
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

SQL Queries

Uploaded by

ravichandu010
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Pizza sales SQL queries

1. Total revenue
select sum(total_price) As total_revenue from pizza_sales

2. Average Order value

Select sum(total_price)/COUNT(distinct order_id) AS


Average_value from pizza_sales

3. Total Pizza Sold

Select SUM(quantity) As Total_Sold From pizza_sales


4. Total Orders
Select Count(Distinct Order_id) AS Total_orders from pizza_sales

5. Avg pizza per Order


Select CAST(CAST(sum(quantity) As Decimal(10,2))/
CAST(count(Distinct order_id) AS Decimal(10,2)) AS Decimal(10,2))
Avg_Pizza_per_order from pizza_sales

6. Daily Trend of pizza orders


Select DATENAME(DW, order_date) as order_day, COUNT(Distinct
order_id) AS total_orders
from pizza_sales
Group by DATENAME(DW, order_date)
7. Trend of orders per month
Select DATENAME(Month, order_date) as Month_name, COUNT(Distinct order_id) AS
total_orders
from pizza_sales
Group by DATENAME(Month, order_date)

8. Percentage of sales by pizza category


Select pizza_category, Sum(total_price) * 100/
(select sum(total_price) from pizza_sales Where MONTH(order_date) = 1) AS PCT_of_sales
from pizza_sales
Where MONTH(order_date) = 1
Group by pizza_category

( Where MONTH(order_date) = 1 is January and MONTH(order_date) = 4 is April )

9. Percentage of sales by pizza size


Select pizza_size, CAST(sum(total_price) As Decimal(10,2)) As Total_sales,
CAST(Sum(total_price) * 100/
(select sum(total_price) from pizza_sales) AS Decimal(10,2)) AS PCT_of_sales from
pizza_sales

Group by pizza_size
Order by PCT_of_sales Desc

10. Top 5 sellers by revenue, total qty and total orders

revenue
Select top 5 Pizza_name, sum(total_price) AS Total_revenue from pizza_sales
Group by Pizza_name
order By Total_revenue desc

total qty
Select top 5 Pizza_name, sum(quantity) AS Total_Quantity from pizza_sales
Group by Pizza_name
order By Total_Quantity desc
total orders

Select top 5 Pizza_name, count(distinct order_id) AS Total_orders from pizza_sales


Group by Pizza_name
order By Total_orders desc

You might also like