• Hugo Kornelis (8/31/2010)


    webrunner (8/31/2010)


    Thanks for the great question. The answer still seems counterintuitive to me - I expected that selecting COUNT(*) would return at least one row (the count result, whether 0 or more), but I guess it works differently in these rare cases.

    Thanks again - I've been learning a lot lately with these questions.

    - webrunner

    But if I added a GROUP BY clause (e.g. GROUP BY Col1), would you expect two rows (with values 3 and 0), or only one row (with value 3)? Why would HAVING behave differently when there is only one group? Or when there are many groups, but none satsifies the condition?

    (I do agree that it's coutnerintuitive, though - heck, I picked the wrong answer myself when I answered the question this morning!)

    Thanks Hugo for the question. I got it right but only because I had a debate with a coworker years ago if it was possible to have a having statement without a group by.

    I also find it interesting that you come up with questions so difficult that even you get them wrong on occasion. lol

    BTW I love your questions, I only get about 1/2 of the right but they always make me think.

    ---------------------------------------------------------------------
    Use Full Links:
    KB Article from Microsoft on how to ask a question on a Forum