4. count(case when)


I’m not sure what the “1” represents after the “WHEN elevation < 1000 THEN”. I’ve tried replacing the “1” with multiple different numbers and the output is still the same.

select state,
	count(case when elevation < 1000 then 1 else null
  end) as count_low_elevation_airports
  from airports
  group by state;

That is because the null cases are not included in the count. 1 or any other non-zero number equates to a boolean true, or NOT NULL.

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