3. case when

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/sql-table-transformation/lessons/conditional-aggregates/exercises/case-when?action=lesson_resume&link_content_target=interstitial_lesson

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
The code is giving output but it is showing that it is not matching the instructions. I have written the code according to the instructions but don’t know what is missing.

Modify the case statement’s such that when the elevation is less than 250, the elevation_tier column returns ‘Low’, when between 250 and 1749 it returns ‘Medium’, and when greater than or equal to 1750 it returns ‘High’.

Be sure to alias the conditional statement as elevation_tier, in your query.

<In this course, it often helps to include a screenshot of your whole web browser – that lets everyone see what you see. If you wish to include a screenshot, add it below this line.>

<If you wish to copy/paste in your code, you can use this next section. This will allow others to copy/paste your code for testing – something that they won’t be able to do with just a screenshot.>

```

select
case
when elevation < 250 then ‘Low’
when elevation between 250 and 1749
then ‘medium’

			when elevation >= 1749 then 'High'
    else 'Unknown'
			
    end as elevation_tier, elevation, count(*)
    from airports
    group by 1;
<do not remove the three backticks above>

SELECT
CASE
WHEN elevation < 250 THEN ‘Low’
WHEN elevation BETWEEN 250 AND 1749
THEN ‘Medium’
WHEN elevation >= 1750 then ‘High’
else ‘Unknown’
END AS elevation_tier
, COUNT(*)
FROM airports
GROUP BY 1;

I think you should write ‘1750’ instead of ‘when elevation >= 1749’ and get rid of ‘elevation’ in the line ‘end as ~~’

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.