-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQL code
203 lines (152 loc) · 5.62 KB
/
SQL code
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
# SQL code for analysis of the data within the dataset
# HERE SIMPLE SQL COMMANDS ARE INITIATED FOR THE OBSERVATION AND ANALYSIS OF THE DATASET
# displaying the entire dataset
SELECT *
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
LIMIT 100;
# displaying the total count of the entire dataset
SELECT Count(1)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
LIMIT 150;
# displaying regular food cunsumption variation
SELECT regular_food_type
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
# displaying the total count of outside food consumption regularly
SELECT count (regular_food_type)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where regular_food_type = 'OUTSIDE';
# displaying solid food type
SELECT _food_type
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where _food_type ='SOLID';
# displaying count of solid food type
SELECT count(_food_type)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where _food_type ='SOLID';
# displaying liquid food type
SELECT _food_type
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where _food_type ='LIQUID';
# displaying count of liquid food type
SELECT count(_food_type)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where _food_type ='LIQUID';
# displaying both solid anad liquid food type
SELECT _food_type
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where _food_type ='BOTH';
# displaying count of Both food type which includes solid and liquid
SELECT count(_food_type)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where _food_type ='BOTH';
# Number of individuals suffering from constipation
SELECT *
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where constipation='Yes';
# count of total constipation
SELECT count (constipation)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where constipation = 'Yes';
# count of total addiction
SELECT count (addiction)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where addiction = 'Yes';
# count of total individuals suffering from deprived energy or from sleepiness
SELECT count (_less_energy_or_sleepy)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where _less_energy_or_sleepy = 'Yes';
# count of total individuals suffering from mood swings due to fast food
SELECT count (MoodSwings)
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where MoodSwings = 'Yes';
# extracting the main colums
SELECT regular_food_type ,
constipation,
addiction,
MoodSwings,
_less_energy_or_sleepy
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2` ;
# extracting details of individuals who suffer from constipation, addiction,moodswings and less energy all symptomns from eating outside regularly
SELECT regular_food_type ,
constipation,
addiction,
MoodSwings,
_less_energy_or_sleepy
FROM `qwiklabs-gcp-04-9dbfb05346d7.HEALTH_CUDDLE_2.HEALTH_CUDDLE_2`
where regular_food_type='OUTSIDE'
AND constipation='Yes'
and addiction='Yes'
and MoodSwings='Yes'
and _less_energy_or_sleepy='Yes';
# extracting details of individuals who suffer from constipation, addiction,moodswings and less energy all symptomns from eating both food type regularly
SELECT (regular_food_type ,
constipation,
addiction,
MoodSwings,
_less_energy_or_sleepy)
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
where regular_food_type='BOTH'
AND constipation='Yes'
and addiction='Yes'
and MoodSwings='Yes'
and _less_energy_or_sleepy='Yes';
# extracting details of individuals who suffer from constipation, addiction,moodswings and less energy all symptomns from eating HOMEMADE food type regularly
SELECT (regular_food_type ,
constipation,addiction,
MoodSwings,
_less_energy_or_sleepy)
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
where regular_food_type='HOME-MADE'
AND constipation='Yes'
and addiction='Yes'
and MoodSwings='Yes'
and _less_energy_or_sleepy='Yes';
SELECT (regular_food_type ,
constipation,
addiction,
MoodSwings,
_less_energy_or_sleepy)
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
where regular_food_type='OUTSIDE'
AND constipation='Yes';
SELECT (regular_food_type ,
constipation,addiction,
MoodSwings,
_less_energy_or_sleepy)
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
where regular_food_type='OUTSIDE'
and addiction='Yes';
SELECT (regular_food_type ,
constipation,
addiction,
MoodSwings,
_less_energy_or_sleepy)
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
where regular_food_type='OUTSIDE'
and MoodSwings='Yes';
SELECT (regular_food_type ,
constipation,
addiction,
MoodSwings,
_less_energy_or_sleepy)
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
where regular_food_type='OUTSIDE'
and _less_energy_or_sleepy='Yes';
# Top 10 individuals who eat outside regularly more than 5 times
SELECT *
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
where regular_food_type='OUTSIDE'
and Number_of_outside_food_per_month > 5
order by Number_of_outside_food_per_month
limit 10;
# display max eaters outside
SELECT *
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
where Number_of_outside_food_per_month > 8;
# Various reasons fo people consuming fast food regularly
SELECT _reason,
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
# or
SELECT *
FROM `qwiklabs-gcp-03-5884439c6d4f.health_cuddle.health_cuddle`
order by _reason;