Draft
Conversation
ivanflee
reviewed
Mar 9, 2019
| WHERE y2016 IS NOT NULL AND y1985 IS NOT NULL | ||
| ``` | ||
| **UGH HOW DO YOU DO THIS PROBLEM!!!!!!** | ||
|
|
There was a problem hiding this comment.
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;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.