7/8 Why Not SUM(CASE WHEN....)

The following code works for the question:

SELECT state,
100.0 * COUNT(CASE WHEN elevation >= 2000 THEN 1 ELSE NULL END) / COUNT(*) AS percentage_high_elevation_airports
FROM airports
GROUP BY state;

My question is, why does it not work if we replace COUNT with SUM? The resulting table either has 0 or 1 entry for each row if we use SUM instead.

My bad, it did work. I’m experiencing some disconnections to the server. I’m new to the forum, anyone know how to take the thread down since its no longer a problem?

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