Count case when


#1


https://www.codecademy.com/en/courses/sql-table-transformation/lessons/conditional-aggregates/exercises/count-case-when

I keep on getting the code incorrect but I don't know what my errors are or whats missing in my code, any help is greatly appreciated!



SELECT state, 
COUNT(CASE WHEN elevation <1000 
THEN 1
ELSE NULL END) 
AS count_low_elevation_airports
FROM airports WHERE state IS NOT NULL
GROUP BY state;


#2

@isaacbuchwald
They are asking you to modify

SELECT    state, 
    COUNT(CASE WHEN elevation >= 2000 THEN 1 ELSE NULL END) as count_high_elevation_aiports 
FROM airports 
GROUP BY state;

Using the same pattern, write a query to count the number of low elevation airports by state where low elevation is defined as less than 1000 ft. ( use space-characters around the operator )


#3

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