SQL table transfromation


#1


Modify the previous elevation example to find the percentage of high elevation airports (elevation >= 2000) by state.
Instructions
1.
Find the percentage of high elevation airports (elevation >= 2000) by state from the airports table.

In the query, alias the percentage column as percentage_high_elevation_airports.


Find the percentage of high elevation airports by state.



SELECT state, 100 * (SUM(CASE WHEN elevation >= 2000 THEN 1 ELSE 0 END)/ COUNT(elevation))AS percentage_high_elevation_airports
FROM airports GROUP BY 1;


#3

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