Subject Re: [firebird-support] sum vs count
Author Ann W. Harrison
At 12:31 AM 2/4/2004, James wrote:

>what is the difference between
>
>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

Essentially the "sum (1)" is equivalent
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