WHEN ____ THEN 1.. what exactly does the 1 represent?


#1


This is the example code. I think I understand the WHEN concept, it's sort of like 'if' in other programming languages, if this is true = when this is true, but what does that int 1 do? Is it a return value that is read as true? Thanks!



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


#2

I think the very next example explained to to me. THEN returns a value, in this case the COUNT function uses that value, so it counts by 1.


#3

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