• Carlo Romagnano (6/23/2011)


    If the condition of the WHERE clause validates to true then the result set is returned. If it does not, the result set is empty.

    This is true only if you do not use COUNT(*):

    select count(*) cnt

    where 1 =0

    One row is returned despite the WHERE condition is false.

    This is true of aggregate functions, not just COUNT(*) -- the where condition filters the input to the aggregate functions, not the output from them.

    Try

    select sum(5)

    where 1 = 0