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

Queries SQL

used for easy understanding of queries sql

Uploaded by

misocix285
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
6 views

Queries SQL

used for easy understanding of queries sql

Uploaded by

misocix285
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF 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; FE Results gf Messages Total_Revenue 1 817360.05083847 2. Average Order Value SELECT (SUM(total_price) / COUNT(DISTINCT order_id)) AS Avg_order_Value FROM pizza_sales FB Results gf Messages ‘Avg_order_Value 1 |38.3072623343546 3, Total Pizzas Sold SELECT SUM(quantity) AS Total_pizza_sold FROM pizza_sales EE Results if Messages Total_pizza_sold 1 (49574 4, Total Orders SELECT COUNT(DISTINCT order_id) AS Total_Orders FROM pizza_sales i Results pi Messages Total_Orders 1 (21350 5, Average Pizzas Per Order SELECT CAST(CAST(SUM(quantity) AS DECIMAL(1@,2)) / CAST (COUNT (DISTINCT order_id) AS DECIMAL(10,2)) AS DECIMAL(1@,2)) AS Avg_Pizzas_per_order FROM pizza_sales EE Results gi Messages ‘Avg_Pizzas_per_order 1 (232 SELECT DATENAME(DW, order_date) AS order_day, COUNT(DISTINCT order_id) AS total_orders FROM pizza_sales GROUP BY DATENAME(DW, order_date) Outpu EE Results gl Messages order_day — total_orders 1 Saturday 3158 2 Wednesday 3024 3 Monday 2794 4 Sunday 2624 5 Friday 3538 6 Thursday 3239 7 Tuesday | 2973, select DATENAME(MONTH, order_date) as Month Name, COUNT(DISTINCT order_id) as Total_Orders from pizza_sales GROUP BY DATENAME(MONTH, order_date) Output Month_Name Total_Orders 6 February 1685 2 June 1773 3 August 1841 4 April 1799 5 May 1853 6 December 1680 7 January 1845 8 September 1667 9 October 1648, 10 July 1935 41 November 1792 12. March 1840 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 Output EB Results pl Messages pizza_category total_revenue PCT 1 Classic } 220053.10 26.91 2 Chicken 195919.50 23.96 3 Veggie 193690.45, 23.68 4 Supreme 208197.00 25.46 SELECT pizza_size, CAST(SUM(total_price) AS DECIMAL(10,2)) as total_revenue, CAST(SUM(total_price) * 108 / (SELECT SUM(total_price) from pizza_sales) ‘AS DECIMAL(1@,2)) AS PCT FROM pizza_sales GROUP BY pizza size ORDER BY pizza_size Output EB Results gi Messages total_revenue PCT 1 EL “| 378318.70 45.89 2M 24998225 30.49 ai (8 178076.50 21.77 4 XL 1407600 1.72 5 XML 1006.60 0.12 SELECT pizza_category, SUM(quantity) as Total_Quantity sold FROM pizza_sales WHERE ONTH(order_date) = 2 GROUP BY pizza_category ORDER BY Total_Quantity Sold DESC Output Fa Results pil Messages pizza_category Total_Quantity_Sold 1 | 14888 2 Supreme 19987 3. Veggie 11649 4 Chicken 11050 SELECT Top 5 pizza_name, SUM(total_price) AS Total_Revenue FROM pizza_sales GROUP BY pizza_name ORDER BY Total_Revenue DESC EE Results gi Messages pizza_name Total_Revenue 1 [The Thai Chicken Pizza | 43434.25 2 The Barbecue Chicken Pizzs 42758 3 TheCalifomia Chicken Pizza 414095 4 TheGassic Deluxe Pizzn 381805 5 The Spicy Italian Pizza 3483125 SELECT Top 5 pizza_name, SUM(total_price) AS Total_Revenue FROM pizza_sales GROUP BY pizza_name ORDER BY Total_Revenue ASC pizza_name Total_Revenue 1 The Brie Carre Pizza 11588,4998130798 2 TheGreen Garden Pizza 1395575 3 TheSpinach Supreme Pizza 1527775 4 TheMediterranean Pizea 153605 5 TheSpinachPesioPizea «15596 SELECT Top 5 pizza_name, SUM(quantity) AS Total_Pizza Sold FROM pizza _sales GROUP BY pizza_name ORDER BY Total_Pizza Sold DESC Output pizza_name Total_Pizza_Sold 1 [The Classic Deluxe Pizza | 2453 2 The Barbecue Chicken Pizza 2432 3. TheHawaiian Pizza 2422 4 The Pepperoni Pizza 2418 5 The Thai Chicken Pizza 27 SELECT TOP 5 pizza_name, SUM(quantity) AS Total_Pizza Sold FROM pizza_sales GROUP BY pizza_name ORDER BY Total Pizza Sold ASC Output © Results il Messages pizza_name The Brie Carre Pizza The Mediterranean Pizza The Calabrese Pizza The Spinach Supreme Pizza oR OR The Soppressata Pizza Total_Pizza_Sold 490 934 937 950 961 SELECT Top 5 pizza_name, COUNT(DISTINCT order_id) AS Total_Orders FROM pizza_sales GROUP BY pizza_name ORDER BY Total_Orders DESC EE Results gl Messages pizza_name _Total_Orders 1 [The Classic Deluxe Pizza 2329 2 The Hawaiian Pizza 2280 3. The Pepperoni Pizza 2278 4 The Barbecue Chicken Pizza 2273 5 The Thai Chicken Pizza 2225 SELECT Top 5 pizza_name, COUN (DISTINCT orden_id) AS Total_orders FROM pizza_sales GROUP BY pizza_name Orders ASC pizza_name. Total_Orders 1 The Brie Carre Pizza 480 The Medierranean Pizza 912, 3 The Spinach Supreme Pizza 918 4 The Calabrese Pizza 918 5 TheChicken PestoPizza «938

You might also like