Count(case when) 'then 1'


The 'THEN 1' confuses me. In the lesson before we used THEN to give a row a name "high, medium,low". In this lesson I can say "THEN " and anything from string to a number (THEN 'A') (THEN 99) and I dont see it change anything in the results. Thank you

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


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