Combining aggregates II question


#1

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;

this is the answer that given by codeacademy, my question is, what is the meaning of “1” in the line of

THEN 1 ELSE 0 END ?


#2

Example

elevation   CASE-when
 column      Result
 1000         0
 2400         1
  800         0
 1500         0
 3000         1
              ==
  SUM-Result  2

#3

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