The basic Aggregate function

  • Shiva N

    Hall of Fame

    Points: 3125

    Comments posted to this topic are about the item The basic Aggregate function

    Thanks,
    Shiva N
    Database Consultant

  • TomThomson

    SSC Guru

    Points: 104773

    Nice straightforward question.

    This is one of those things (like the handling of SUM) the makes me think that someone had a screw loose when they were specifying how aggregates worked in unusual circumetances.

    Tom

  • This was removed by the editor as SPAM

  • david.gugg

    SSCertifiable

    Points: 5692

    I think this kind of makes sense if you come at it from the Oracle perspective. In Oracle, to select values you have to go against the SYS.DUAL table, a table with a single dummy record. For example, the equivalent of SELECT GETDATE(); in Oracle would be SELECT sysdate FROM dual;. So the equivalent of SELECT COUNT(1); in Oracle would be SELECT COUNT(1) FROM dual;, which would return 1.


    [font="Tahoma"]Personal blog relating fishing to database administration:[/font]

    [font="Comic Sans MS"]https://davegugg.wordpress.com[/url]/[/font]

  • webrunner

    SSC-Dedicated

    Points: 30219

    Thanks, great question. The behavior is not at all what I expected, but it is good to know.

    - webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • sknox

    SSChampion

    Points: 12284

    david.gugg (7/25/2016)


    I think this kind of makes sense if you come at it from the Oracle perspective. In Oracle, to select values you have to go against the SYS.DUAL table, a table with a single dummy record. For example, the equivalent of SELECT GETDATE(); in Oracle would be SELECT sysdate FROM dual;. So the equivalent of SELECT COUNT(1); in Oracle would be SELECT COUNT(1) FROM dual;, which would return 1.

    So what happens in Oracle if you just execute SELECT GETDATE(); ?

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    david.gugg (7/25/2016)


    I think this kind of makes sense if you come at it from the Oracle perspective. In Oracle, to select values you have to go against the SYS.DUAL table, a table with a single dummy record. For example, the equivalent of SELECT GETDATE(); in Oracle would be SELECT sysdate FROM dual;. So the equivalent of SELECT COUNT(1); in Oracle would be SELECT COUNT(1) FROM dual;, which would return 1.

    Didn't know that about Oracle.

  • Koen Verbeeck

    SSC Guru

    Points: 258965

    Easy one, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply