-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQL Blinkit Project.sql
More file actions
227 lines (172 loc) · 8.77 KB
/
SQL Blinkit Project.sql
File metadata and controls
227 lines (172 loc) · 8.77 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
use My_project;
select * from Grocery_Store;
#Q2 Write an SQL query to show all Item_Identifier
select Item_Identifier from Grocery_Store;
#Q3 Write an SQL query to show count of total Item_Identifier
select count(Item_Identifier) from Grocery_Store;
#Q4 Write an SQL query to show maximum Item Weight.
select max(Item_Weight) from Grocery_Store;
#Q5 Write an SQL query to show minimum Item Weight.
select min(Item_Weight) from Grocery_Store;
#Q6 Write an SQL query to show average Item_Weight
select avg(Item_Weight) from Grocery_Store;
#Q7 Write an SQL query to show count of Item_Fat_Content WHERE Item_Fat_Content is Low Fat.
select count(Item_Fat_Content) from Grocery_Store where Item_Fat_Content = 'Low Fat';
#Q8 Write an SQL query to show count of Item_Fat_Content WHERE Item_Fat_Content is Regular.
select count(Item_Fat_Content) from Grocery_Store where Item_Fat_Content = 'Regular';
#Q9 Write an SQL query to show maximum Item_MRP
select max(Item_MRP) from Grocery_Store;
#Q10 Write an SQL query to show minimum Item_MRP
select min(Item_MRP) from Grocery_Store;
#Q11 Write an SQL query to show Item_Identifier , Item_Fat_Content ,Item_Type, Item_MRP whose Item_MRP is greater than 200.
select Item_Identifier , Item_Fat_Content ,Item_Type,Item_MRP from Grocery_Store where Item_MRP>200;
#Q12 Write an SQL query to show maximum Item_MRP WHERE Item_Fat_Content is Low Fat
select max(Item_MRP) from Grocery_Store where Item_Fat_Content = 'Low Fat';
#Q13 Write an SQL query to show minimum Item_MRP whose Item_Fat_Content is Low Fat
select min(Item_MRP) from Grocery_Store where Item_Fat_Content = 'Low Fat';
#Q14 Write an SQL query to show ALL DATA WHERE item MRP is BETWEEN 50 to 100
select * from Grocery_Store where Item_MRP between 50 and 100;
#Q15 Write an SQL query to show ALL UNIQUE value of Item_Fat_Content
select distinct Item_Fat_Content from Grocery_Store;
#Q16 Write an SQL query to show ALL UNIQUE value of Item_Type
select distinct Item_Type from Grocery_Store;
#Q17 Write an SQL query to show ALL DATA in descending ORDER by Item MRP
select * from Grocery_Store order by Item_MRP desc;
#Q18 Write an SQL query to show ALL DATA in ascending ORDER by Item_Outlet_Sales
select * from Grocery_Store order by Item_Outlet_Sales asc;
#Q19 Write an SQL query to show ALL DATA in ascending by Item_Type
select * from Grocery_Store order by Item_Type asc;
#Q20 Write an SQL query to show DATA of item_type dairy & Meat
select * from Grocery_Store where Item_Type in ('Dairy','Meat');
#Q21 Write an SQL query to show ALL UNIQUE value of Outlet_Size
select distinct Outlet_Size from Grocery_Store;
#Q22 Write an SQL query to show ALL UNIQUE value of Outlet_Location_Type
select distinct Outlet_Location_Type from Grocery_Store;
#Q23 Write an SQL query to show ALL UNIQUE value of Outlet_Type
select distinct Outlet_Type from Grocery_Store;
#Q24 Write an SQL query to show count of number of items by Item_Type and order it in descending order
SELECT Item_Type , count(Item_Identifier) as No_Of_Item
FROM Grocery_Store
GROUP BY Item_Type
ORDER BY No_Of_Item DESC;
#Q25 Write an SQL query to show count of number of items by Outlet_Size and ordered it in ascending order
SELECT Outlet_Size , count(Item_Identifier) as No_Of_Item
FROM Grocery_Store
GROUP BY Outlet_Size
ORDER BY No_Of_Item asc;
#Q26 Write an SQL query to show count of number of items by Outlet_Type and ordered it in descending order.
SELECT Outlet_Type , count(Item_Identifier)as No_Of_Item
FROM Grocery_Store
GROUP BY Outlet_Type
ORDER BY No_Of_Item desc;
#Q27 Write an SQL query to show count of items by Outlet_Location_Type and order it in descending order
SELECT Outlet_Location_Type , count(Item_Identifier) as No_Of_Item
FROM Grocery_Store
GROUP BY Outlet_Location_Type
ORDER BY No_Of_Item desc;
#Q28 Write an SQL query to show maximum MRP by Item_Type
SELECT Item_Type, Max(Item_MRP) as Max_MRP
FROM Grocery_Store
GROUP BY Item_Type;
#Q29 Write an SQL query to show minimum MRP by Item_Type
SELECT Item_Type, min(Item_MRP) as Min_MRP
FROM Grocery_Store
GROUP BY Item_Type;
#Q30 Write an SQL query to show minimum MRP by Outlet_Establishment_Year and order it in descending order.
SELECT Outlet_Establishment_Year, min(Item_MRP) as Min_MRP
FROM Grocery_Store
GROUP BY Outlet_Establishment_Year order by Min_MRP desc ;
#Q31 Write an SQL query to show maximum MRP by Outlet_Establishment_Year and order it in descending order.
SELECT Outlet_Establishment_Year, Max(Item_MRP) as Max_MRP
FROM Grocery_Store
GROUP BY Outlet_Establishment_Year order by Max_MRP desc;
#Q32 Write an SQL query to show average MRP by Outlet_Size and order it in descending order.
SELECT Outlet_Size, avg(Item_MRP)as Average_MRP
FROM Grocery_Store
GROUP BY Outlet_Size order by Average_MRP desc;
#Q33 Write an SQL query to Average MRP by Outlet_Type and ordered in ascending order.
SELECT Outlet_Type, avg(Item_MRP) as Average_MRP
FROM Grocery_Store
GROUP BY Outlet_Type order by Average_MRP asc;
#Q34 Write an SQL query to show maximum MRP by Outlet_Type
SELECT Outlet_Type, max(Item_MRP) as Max_MRP
FROM Grocery_Store
GROUP BY Outlet_Type order by Max_MRP asc;
#Q35 Write an SQL query to show maximum Item_Weight by Item_Type
SELECT Item_Type , max(Item_Weight)as max_weight
FROM Grocery_Store
GROUP BY Item_Type
ORDER BY max_weight DESC;
#Q36 Write an SQL query to show maximum Item_Weight by Outlet_Establishment_Year
SELECT Outlet_Establishment_Year , max(Item_Weight) as max_weight
FROM Grocery_Store
GROUP BY Outlet_Establishment_Year
ORDER BY max_weight asc;
#Q37 Write an SQL query to show minimum Item_Weight by Outlet_Type
SELECT Outlet_Type , min(Item_Weight) as min_weight
FROM Grocery_Store
GROUP BY Outlet_Type
ORDER BY min_weight desc;
#Q38 Write an SQL query to show average Item_Weight by Outlet_Location_Type and arrange it by descending order
SELECT Outlet_Location_Type , avg(Item_Weight)as Average_weight
FROM Grocery_Store
GROUP BY Outlet_Location_Type
ORDER BY Average_weight desc;
#Q39 Write an SQL query to show maximum Item_Outlet_Sales by Item_Type
SELECT Item_Type, Max(Item_Outlet_Sales) as Max_sales
FROM Grocery_Store
GROUP BY Item_Type;
#Q40 Write an SQL query to show minimum Item_Outlet_Sales by Item_Type
SELECT Item_Type, min(Item_Outlet_Sales) as Min_sales
FROM Grocery_Store
GROUP BY Item_Type;
#Q41 Write an SQL query to show minimum Item_Outlet_Sales by Outlet_Establishment_Year
SELECT Outlet_Establishment_Year, min(Item_Outlet_Sales) as Min_sales
FROM Grocery_Store
GROUP BY Outlet_Establishment_Year order by Min_sales desc;
#Q42 Write an SQL query to show maximum Item_Outlet_Sales by Outlet_Establishment_Year and order it by descending order
SELECT Outlet_Establishment_Year, Max(Item_Outlet_Sales) as Max_sales
FROM Grocery_Store
GROUP BY Outlet_Establishment_Year order by Max_sales desc;
#Q43 Write an SQL query to show average Item_Outlet_Sales by Outlet_Size and order it it descending order
SELECT Outlet_Size, avg(Item_Outlet_Sales) as Average_sales
FROM Grocery_Store
GROUP BY Outlet_Size order by Average_sales desc;
#Q44 Write an SQL query to show average Item_Outlet_Sales by Outlet_Type
SELECT Outlet_Type, avg(Item_Outlet_Sales) as Average_sales
FROM Grocery_Store
GROUP BY Outlet_Type order by Average_sales asc;
#Q45 Write an SQL query to show maximum Item_Outlet_Sales by Outlet_Type
SELECT Outlet_Type, max(Item_Outlet_Sales) as Max_sales
FROM Grocery_Store
GROUP BY Outlet_Type order by Max_sales asc;
#Q46 Write an SQL query to show total Item_Outlet_Sales by Item_Type
select Item_Type, sum(Item_Outlet_Sales) as total_sales
from Grocery_Store
group by Item_Type
order by total_sales desc;
#Q47 Write an SQL query to show total Item_Outlet_Sales by Item_Fat_Content
select Item_Fat_Content, sum(Item_Outlet_Sales)total_sales
from Grocery_Store
group by Item_Fat_Content
order by total_sales desc;
#Q48 Write an SQL query to show maximum Item_Visibility by Item_Type
select Item_Type, Max(Item_Visibility) as max_visibility
from Grocery_Store
group by Item_Type
order by max_visibility desc;
#Q49 Write an SQL query to show Minimum Item_Visibility by Item_Type
select Item_Type, Min(Item_Visibility) as min_visibility
from Grocery_Store
group by Item_Type
order by min_visibility desc;
#Q50 Write an SQL query to show total Item_Outlet_Sales by Item_Type but only WHERE Outlet_Location_Type is Tier 1
select Item_Type, sum(Item_Outlet_Sales) as Total_sales
from Grocery_Store where Outlet_Location_Type = 'Tier 1'
group by Item_Type
order by Total_sales desc;
#Q51 Write an SQL query to show total Item_Outlet_Sales by Item_Type WHERE Item_Fat_Content is ONLY Low Fat & LF
select Item_Type, sum(Item_Outlet_Sales) as Total_sales
from Grocery_Store where Item_Fat_Content in ('Low Fat', 'LF')
group by Item_Type
order by Total_sales desc;