You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I didn't like what the question was asking and took a sum of each continents GDP per capita instead of any other metric for the sake of time. However this metric is a bit strange but this data needs more information in order to properly answer the question, EG, population of each country in the year 2012
3\. For the year 2012, create a 3 column, 1 row report showing the percent share of gdp_per_capita for the following regions:
@@ -155,8 +211,61 @@ AUS Australia OC Oceania 2004 30464.00376
155
211
------ | ------ | -------------
156
212
25.0% | 25.0% | 50.0%
157
213
214
+
SELECT
215
+
CONCAT(ROUND(((SELECT
216
+
SUM(gdp_per_capita)
217
+
FROM
218
+
braintree.gdp_join
219
+
WHERE
220
+
year = 2012 AND continent_name = 'Asia') / (SELECT
221
+
SUM(gdp_per_capita)
222
+
FROM
223
+
braintree.gdp_join
224
+
WHERE
225
+
year = 2012)) * 100,
226
+
1),
227
+
'%') AS 'Asia',
228
+
CONCAT(ROUND(((SELECT
229
+
SUM(gdp_per_capita)
230
+
FROM
231
+
braintree.gdp_join
232
+
WHERE
233
+
year = 2012
234
+
AND continent_name = 'Europe') / (SELECT
235
+
SUM(gdp_per_capita)
236
+
FROM
237
+
braintree.gdp_join
238
+
WHERE
239
+
year = 2012)) * 100,
240
+
1),
241
+
'%') AS 'Europe',
242
+
CONCAT(ROUND(((SELECT
243
+
SUM(gdp_per_capita)
244
+
FROM
245
+
braintree.gdp_join
246
+
WHERE
247
+
year = 2012 AND continent_name != 'Asia'
248
+
AND continent_name != 'Europe') / (SELECT
249
+
SUM(gdp_per_capita)
250
+
FROM
251
+
braintree.gdp_join
252
+
WHERE
253
+
year = 2012)) * 100,
254
+
1),
255
+
'%') AS 'Rest of World'
256
+
257
+
/* Results of This Query Below! */
258
+
259
+
Asia Europe Rest of World
260
+
28.3% 42.2% 29.4%
261
+
262
+
PS:
263
+
I didn't like/ understand what the question was asking and took a sum of each continents GDP per capita instead of any other metric for the sake of time. However this metric is a bit strange but this data needs more information in order to properly answer the question, EG, population of each country in the year 2012 to get GDP of each country. Otherwise, continents with more countries are skewed simply because there are more of them, not necessarily a reflection of true GDP % share.
264
+
158
265
4a\. What is the count of countries and sum of their related gdp_per_capita values for the year 2007 where the string 'an' (case insensitive) appears anywhere in the country name?
159
266
267
+
268
+
160
269
4b\. Repeat question 4a, but this time make the query case sensitive.
161
270
162
271
5\. Find the sum of gpd_per_capita by year and the count of countries for each year that have non-null gdp_per_capita where (i) the year is before 2012 and (ii) the country has a null gdp_per_capita in 2012. Your result should have the columns:
0 commit comments