• Toby Harman (8/30/2010)


    Nice. Helps if I remember that 6 > 5 :blush:

    :laugh: I feel your pain. I managed to miss the point as well - on my own question! :w00t:

    Thanks everyone for the nice words!

    For those who want to see for themselves, or try playing around with the issue, here is some repro code:

    CREATE TABLE #QotD (Col1 int, Col2 int);

    go

    INSERT INTO #QotD (Col1, Col2)

    SELECT 1, 1 UNION ALL

    SELECT 1, 2 UNION ALL

    SELECT 1, 3 UNION ALL

    SELECT 2, 4 UNION ALL

    SELECT 2, 5 UNION ALL

    SELECT 2, 6;

    go

    SELECT COUNT(*)

    FROM #QotD

    WHERE Col2 <> 4

    HAVING MAX(Col2) < 5;

    go

    DROP TABLE #QotD;

    go


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/