-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpizza.sql_1.sql
More file actions
37 lines (32 loc) · 1 KB
/
Copy pathpizza.sql_1.sql
File metadata and controls
37 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- Total number of orders placed
select count(order_id) as total_orders
from orders;
-- Total revenue generated from pizza sales
select round(sum(order_details.quantity * pizzas.price),2) as total_sales
from order_details
join pizzas
on pizzas.pizza_id = order_details.pizza_id;
-- Highest priced pizzas
select pizza_types.name, pizzas.price
from pizza_types
join pizzas
on pizza_types.pizza_type_id = pizzas.pizza_type_id
order by pizzas.price desc
limit 1;
-- Most common pizza size ordered
select pizzas.size, count(order_details.order_details_id) as order_count
from pizzas
join order_details
on order_details.pizza_id = pizzas.pizza_id
group by pizzas.size
order by order_count desc;
-- Top 5 most ordered pizza types along with their quantities
select pizza_types.name, sum(order_details.quantity) as quantity
from pizza_types
join pizzas
on pizza_types.pizza_type_id = pizzas.pizza_type_id
join order_details
on order_details.pizza_id = pizzas.pizza_id
group by pizza_types.name
order by quantity desc
limit 5;