Skip to content

Commit b1e67c6

Browse files
Finished Question 5
1 parent a844e88 commit b1e67c6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

alexander_connelly_code_challenge.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,39 @@ count(*) sum(gdp_per_capita)
292292
- country_count
293293
- total
294294

295+
296+
SELECT
297+
year, COUNT(DISTINCT (country_name)) as country_count, SUM(gdp_per_capita) as total
298+
FROM
299+
braintree.gdp_join
300+
WHERE
301+
country_code IN (SELECT
302+
t1.country_code
303+
FROM
304+
braintree.countries t1
305+
LEFT JOIN
306+
(SELECT
307+
*
308+
FROM
309+
per_capita
310+
WHERE
311+
year = 2012) t2 ON (t1.country_code = t2.country_code)
312+
WHERE
313+
year IS NULL)
314+
GROUP BY year;
315+
316+
Result:
317+
318+
year country_count total
319+
2004 14 435360.5308659
320+
2005 14 453525.7332075
321+
2006 13 491425.8090778
322+
2007 13 580931.606779
323+
2008 10 574016.20641
324+
2009 8 399526.161602
325+
2010 4 179750.82754000003
326+
2011 4 199152.680469
327+
295328
6\. All in a single query, execute all of the steps below and provide the results as your final answer:
296329

297330
a. create a single list of all per_capita records for year 2009 that includes columns:

0 commit comments

Comments
 (0)