Subject | Re: [firebird-support] sum vs count |
---|---|
Author | Ann W. Harrison |
Post date | 2004-02-04T15:43:57Z |
At 12:31 AM 2/4/2004, James wrote:
to count(*). Count(<field>) is slightly
different as it does not count rows with
a null value of <field>. In this case,
that matters not at all. To the best of
my understanding these queries are equivalent.
And do yourself a favor, lose the quotes.
Crankily,
Ann
>what is the difference betweenEssentially the "sum (1)" is equivalent
>
>select "counterno", sum(1)
> from "counter"
> group by "counterno"
> having sum(1) > 1
>
>and
>
>select "counterno", count("counterno")
> from "counter"
> group by "counterno"
> having count("counterno") > 1
to count(*). Count(<field>) is slightly
different as it does not count rows with
a null value of <field>. In this case,
that matters not at all. To the best of
my understanding these queries are equivalent.
And do yourself a favor, lose the quotes.
Crankily,
Ann