forked from saptarshisarkar20/Hacktoberfest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswiggysolution.sql
90 lines (76 loc) · 2.02 KB
/
swiggysolution.sql
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use swiggy;
#Q1
select count(distinct restaurant_name)
as high_rated_restaurants
from swiggy
where rating>4.5;
#Q2
select city,count(distinct restaurant_name)
as restaurant_count from swiggy
group by city
order by restaurant_count desc
limit 1;
#Q3
select count(distinct restaurant_name) as pizza_restaurants
from swiggy
where restaurant_name like '%Pizza%';
#Q4
select cuisine,count(*) as cuisine_count
from swiggy
group by cuisine
order by cuisine_count desc
limit 1;
#Q5
select city, avg(rating) as average_rating
from swiggy group by city;
#Q6
select distinct restaurant_name,
menu_category,max(price) as highestprice
from swiggy where menu_category='Recommended'
group by restaurant_name,menu_category;
#Q7
select distinct restaurant_name,cost_per_person
from swiggy where cuisine<>'Indian'
order by cost_per_person desc
limit 5;
#Q8
select distinct restaurant_name,cost_per_person
from swiggy where cost_per_person>(
select avg(cost_per_person) from swiggy);
#Q9
select distinct t1.restaurant_name,t1.city,t2.city
from swiggy t1 join swiggy t2
on t1.restaurant_name=t2.restaurant_name and
t1.city<>t2.city;
#Q10
select distinct restaurant_name,menu_category
,count(item) as no_of_items from swiggy
where menu_category='Main Course'
group by restaurant_name,menu_category
order by no_of_items desc limit 1;
#Q11
select distinct restaurant_name,
(count(case when veg_or_nonveg='Veg' then 1 end)*100/
count(*)) as vegetarian_percetage
from swiggy
group by restaurant_name
having vegetarian_percetage=100.00
order by restaurant_name;
#Q12
select distinct restaurant_name,
avg(price) as average_price
from swiggy group by restaurant_name
order by average_price limit 1;
#Q13
select distinct restaurant_name,
count(distinct menu_category) as no_of_categories
from swiggy
group by restaurant_name
order by no_of_categories desc limit 5;
#Q14
select distinct restaurant_name,
(count(case when veg_or_nonveg='Non-veg' then 1 end)*100
/count(*)) as nonvegetarian_percentage
from swiggy
group by restaurant_name
order by nonvegetarian_percentage desc limit 1;