Errors in the high-elevation query

<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.>

This is one of the questions in the conditional aggregate
Find the percentage of high elevation airports (elevation >= 2000) by state from the airports table.
<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
The error is given like this:
Find the percentage of high elevation airports by state.
<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.>
Can anyone tell what’s wrong with my code? Thank you!

<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 state, 100.0 * (sum(case when elevation >= 2000 then 1 else 0 end)/sum(elevation)) as percentage_high_elevation_airports
from airports
group by state;

```
<do not remove the three backticks above>

An average would imply dividing by a count. The sum is in the numerator.

I don’t quite get your point. Would you like to clarify it?

... / count(*)

Unfortunately, there is still something wrong after I tried your way…

The table won’t be drawn if the SCT fails. The SQL might be right. Let’s fiddle with the inputs and see how the SCT responds.

select state, 100.0 * sum(case when elevation >= 2000 then 1 else 0 end) / count(*)

What does this result in?

no from… gives me error again.
The case syntax gives me a binary result. Is it the error come from the sum(binary results)?

2 posts were split to a new topic: Stuck on high elevation

Be sure you haven’t removed the rest of your code. The above is what goes before AS.

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