Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, July 18, 2016

SQL: Table Transformation Lesson 20 Sample Solution


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

Sample Solution:
SELECT state, 100.0 * sum(CASE WHEN elevation >= 2000 THEN 1 ELSE 0 END) / count(*)  as percentage_high_elevation_airports FROM airports GROUP BY state;

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts