-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproject_01_big_mart_sales_analysis.sql
More file actions
307 lines (215 loc) · 9.92 KB
/
project_01_big_mart_sales_analysis.sql
File metadata and controls
307 lines (215 loc) · 9.92 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# Create a database
create database project01;
# Use that database
use project01;
# Table big_mart
select * from big_mart;
# [ SQL Analysis on Big Mart Sales Dataset. ]
# 1) WRITE a sql query to show all Item_Identifier.
Select Item_Identifier from big_mart;
# 2) WRITE a sql query to show count of total Item_Identifier.
Select count(Item_Identifier) from big_mart;
# 3) WRITE a sql query to show maximum Item Weight.
Select Item_Identifier , max(Item_Weight) from big_mart;
# 4) WRITE a query to show minimun Item Weight.
Select Item_Identifier , min(Item_Weight) from big_mart;
# 5) WRITE a query to show average Item_Weight.
Select Item_Identifier , avg(Item_Weight) from big_mart;
# 6) WRITE a query to show count OF Item_Fat_Content WHERE Item_Fat_Content IS Low Fat.
Select count(Item_Fat_Content) from big_mart where Item_Fat_Content = 'Low Fat';
# 7) WRITE a query to show count OF Item_Fat_Content WHERE Item_Fat_Content IS Regular.
Select count(Item_Fat_Content) from big_mart where Item_Fat_Content = 'Regular';
# 8) WRITE a query TO show maximum Item_MRP.
Select max(Item_MRP) from big_mart;
# 9) WRITE a query TO show minimum Item_MRP.
Select min(Item_MRP) from big_mart;
# 10) WRITE a query to show Item_Identifier , Item_Fat_Content,Item_Type,Item_MRP and Item_MRP IS
# greater than 200.
Select Item_Identifier , Item_Fat_Content , Item_Type , Item_MRP from big_mart
where Item_MRP > 200;
# 11) WRITE a query to show maximum Item_MRP WHERE Item_Fat_Content IS Low Fat.
Select max(Item_MRP) from big_mart where Item_Fat_Content = 'Low Fat';
# 12) WRITE a query to show minimum Item_MRP AND Item_Fat_Content IS Low Fat.
Select min(Item_MRP) from big_mart where Item_Fat_Content = 'Low Fat';
# 13) WRITE a query to show ALL DATA WHERE item MRP IS BETWEEN 50 TO 100.
Select * from big_mart where Item_MRP between 50 and 100;
# 14) WRITE a query to show ALL UNIQUE value Item_Fat_Content.
Select distinct(Item_Fat_Content) from big_mart;
# 15) WRITE a query to show ALL UNIQUE value Item_Type.
Select distinct(Item_Type) from big_mart;
# 16) WRITE a query to show ALL DATA IN descending ORDER BY Item MRP.
Select * from big_mart order by Item_MRP desc;
# 17) WRITE a query to show ALL DATA IN ascending ORDER BY Item_Outlet_Sales.
Select * from big_mart order by Item_Outlet_Sales asc;
# 18) WRITE a query to show ALL DATA IN ascending BY Item_Type.
Select * from big_mart order by Item_Type asc;
# 19) WRITE a query to show DATA OF item_type dairy & Meat.
Select * from big_mart where Item_Type in ('Dairy','Meat');
# 20) WRITE a query to show ALL UNIQUE value OF Outlet_Size.
Select distinct(Outlet_Size) from big_mart;
# 21) WRITE a query to show ALL UNIQUE value OF Outlet_Location_Type.
Select distinct(Outlet_Location_Type) from big_mart;
# 22) WRITE a query to show ALL UNIQUE value OF Outlet_Type.
Select distinct(Outlet_Type) from big_mart;
# 23) WRITE a query to show count NO. OF item BY Item_Type AND ordered it IN descending.
Select Item_Type ,count(Item_Identifier) as No_of_item
from big_mart
group by Item_Type
order by No_of_item desc;
# 24) WRITE a query to show count NO. OF item BY Outlet_Size AND ordered it IN ascending.
Select Outlet_Size , count(Item_Identifier) as No_of_item
from big_mart
group by Outlet_Size
order by No_of_item asc;
# 25) WRITE a query TO show count NO. OF item BY Outlet_Establishment_Year AND ordered it IN ascening.
Select Outlet_Establishment_Year , count(Item_Identifier) as No_of_item
from big_mart
group by Outlet_Identifier
order by No_of_item asc ;
# 26) WRITE a query to show count NO. OF item BY Outlet_Type AND ordered it IN descending.
Select Outlet_Type , count(Item_Identifier) as No_of_item
from big_mart
group by Outlet_Type
order by No_of_item desc ;
# 27) WRITE a query to show count of item BY Outlet_Location_Type AND ordered it IN descending.
Select Outlet_Location_Type , count(Item_Identifier) as No_of_item
from big_mart
group by Outlet_Location_Type
order by No_of_item desc ;
# 28) WRITE a query to show maximum MRP BY Item_Type.
Select Item_Type ,max(Item_MRP) as Max_MRP
from big_mart
group by Item_Type ;
# 29) WRITE a query to show minimum MRP BY Item_Type.
Select Item_Type ,min(Item_MRP) as Min_MRP
from big_mart
group by Item_Type ;
# 30) WRITE a query to show minimum MRP BY Outlet_Establishment_Year AND ordered it IN descending.
Select Outlet_Establishment_Year ,min(Item_MRP) as Min_MRP
from big_mart
group by Outlet_Establishment_Year
order by Min_MRP desc ;
# 31) WRITE a query to show maximum MRP BY Outlet_Establishment_Year AND ordered IN descending.
Select Outlet_Establishment_Year ,max(Item_MRP) as Max_MRP
from big_mart
group by Outlet_Establishment_Year
order by Max_MRP desc ;
# 32) WRITE a query to show average MRP BY Outlet_Size AND ordered IN descending.
Select Outlet_Size , avg(Item_MRP) as AVG_MRP
from big_mart
group by Outlet_Size
order by AVG_MRP desc ;
# 33) WRITE a query to show average MRP BY Outlet_Size AND ordered IN descending.
Select Outlet_Size , avg(Item_MRP) as AVG_MRP
from big_mart
group by Outlet_Size
order by AVG_MRP desc ;
# 34) WRITE a query to show Average MRP BY Outlet_Type AND ordered IN ascending.
Select Outlet_Type , avg(Item_MRP) as AVG_MRP
from big_mart
group by Outlet_Type
order by AVG_MRP asc ;
# 35) WRITE a query to show maximum MRP BY Outlet_Type AND ordered IN ascending.
Select Outlet_Type , max(Item_MRP) as MAX_MRP
from big_mart
group by Outlet_Type
order by MAX_MRP asc ;
# 36) WRITE a query to show maximum Item_Weight BY Item_Type AND ordered IN descending.
Select Item_Type , max(Item_Weight) as MAX_Weight
from big_mart
group by Item_Type
order by MAX_Weight desc ;
# 37) WRITE a query to show maximum Item_Weight BY Outlet_Establishment_Year AND ordered IN ascending.
Select Outlet_Establishment_Year , max(Item_Weight) as MAX_Weight
from big_mart
group by Outlet_Establishment_Year
order by MAX_Weight asc ;
# 38) WRITE a query to show minimum Item_Weight BY Outlet_Type AND ordered IN descending.
Select Outlet_Type , min(Item_Weight) as MIN_Weight
from big_mart
group by Outlet_Type
order by MIN_Weight desc;
# 39) WRITE a query to show average Item_Weight BY Outlet_Location_Type ORDER BY descending.
Select Outlet_Location_Type , avg(Item_Weight) as AVG_Weight
from big_mart
group by Outlet_Location_Type
order by AVG_Weight desc;
# 40) WRITE a query to show maximum Item_Outlet_Sales BY Item_Type.
Select Item_Type , max(Item_Outlet_Sales) as MAX_Outlet_sales
from big_mart
group by Item_Type;
# 41) WRITE a query to show minimum Item_Outlet_Sales BY Item_Type.
Select Item_Type , min(Item_Outlet_Sales) as MIN_Outlet_sales
from big_mart
group by Item_Type;
# 42) WRITE a query to show minimum Item_Outlet_Sales BY Outlet_Establishment_Year ORDER BY descending.
Select Outlet_Establishment_Year , min(Item_Outlet_Sales) as MIN_Outlet_sales
from big_mart
group by Outlet_Establishment_Year
order by MIN_Outlet_sales desc;
# 43) WRITE a query to show maximum Item_Outlet_Sales BY Outlet_Establishment_Year ordered BY descending.
Select Outlet_Establishment_Year , max(Item_Outlet_Sales) as MAX_Outlet_sales
from big_mart
group by Outlet_Establishment_Year
order by MAX_Outlet_sales desc;
# 44) WRITE a query to show average Item_Outlet_Sales BY Outlet_Size AND ORDER it descending.
Select Outlet_Size , avg(Item_Outlet_Sales) as AVG_Outlet_sales
from big_mart
group by Outlet_Size
order by AVG_Outlet_sales desc ;
# 45) WRITE a query to show average Item_Outlet_Sales BY Outlet_Size.
Select Outlet_Size , avg(Item_Outlet_Sales) as AVG_Outlet_sales
from big_mart
group by Outlet_Size;
# 46) WRITE a query to show average Item_Outlet_Sales BY Outlet_Type AND ordered IN ascending.
Select Outlet_Type , avg(Item_Outlet_Sales) as AVG_Outlet_sales
from big_mart
group by Outlet_Type
order by AVG_Outlet_sales asc ;
# 47) WRITE a query to show maximum Item_Outlet_Sales BY Outlet_Type AND ordered IN ascending.
Select Outlet_Type , max(Item_Outlet_Sales) as MAX_Outlet_sales
from big_mart
group by Outlet_Type
order by MAX_Outlet_sales asc ;
# 48) WRITE a query to show total Item_Outlet_Sales BY Outlet_Establishment_Year AND ORDER it descending.
Select Outlet_Establishment_Year , sum(Item_Outlet_Sales) as total_Outlet_sales
from big_mart
group by Outlet_Establishment_Year
order by total_Outlet_sales desc;
# 49) WRITE a query to show total Item_Outlet_Sales BY Item_Type AND ORDER it descending.
Select Item_Type , sum(Item_Outlet_Sales) as total_Outlet_sales
from big_mart
group by Item_Type
order by total_Outlet_sales desc;
# 50) WRITE a query to show total Item_Outlet_Sales BY Outlet_Location_Type AND ORDER it descending.
Select Outlet_Location_Type , sum(Item_Outlet_Sales) as total_Outlet_sales
from big_mart
group by Outlet_Location_Type
order by total_Outlet_sales desc;
# 51) WRITE a query to show total Item_Outlet_Sales BY Item_Fat_Content AND ORDER it descending.
Select Item_Fat_Content , sum(Item_Outlet_Sales) as total_Outlet_sales
from big_mart
group by Item_Fat_Content
order by total_Outlet_sales desc;
# 52) WRITE a query to show maximum Item_Visibility BY Item_Type AND ORDER it descending.
Select Item_Type , max(Item_Visibility) as MAX_Visibility
from big_mart
group by Item_Type
order by MAX_Visibility desc ;
# 53) WRITE a query to show Minimum Item_Visibility BY Item_Type AND ORDER it descending.
Select Item_Type , min(Item_Visibility) as MIN_Visibility
from big_mart
group by Item_Type
order by MIN_Visibility desc ;
# 54) WRITE a 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_Outlet_sales, Outlet_Location_Type
from big_mart
where Outlet_Location_Type = 'Tier 1'
group by Item_Type
order by total_Outlet_sales desc ;
# 55) WRITE a 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_Outlet_sales, Item_Fat_Content
from big_mart
where Item_Fat_Content in ('Low Fat','LF')
group by Item_Type
order by total_Outlet_sales desc ;