Skip to content

Conversation

@maria65mj
Copy link
Contributor

No description provided.

WHERE y2016 IS NOT NULL AND y1985 IS NOT NULL
```
**UGH HOW DO YOU DO THIS PROBLEM!!!!!!**

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I am correct, but based on the proposed output, the region_name needs to be aggregated using the string_agg() function and not out on its own. And then we can group by the growth (what you have as 'comparison_growth'.

Based on your code it would look something like this:

SELECT  
      (CASE WHEN (y2016::float/y1985)>=3.652 THEN 'High Growth' ELSE 'Low Growth' END) as comparison_growth,
      STRING_AGG(region_name,', ') 
FROM (SELECT region_name, 
      sum(CASE WHEN year=1985 THEN gdp_per_capita ELSE NULL END) AS y1985,
      sum(CASE WHEN year=2016 THEN gdp_per_capita ELSE NULL END) AS y2016
      FROM public.gdp
      GROUP BY region_name) as original
WHERE y2016 IS NOT NULL AND y1985 IS NOT NULL
GROUP BY comparison_growth;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants