Re: Counting propositions
Date: Tue, 15 Jun 2004 08:44:07 -0700
Message-ID: <u_Ezc.25$Ok2.108_at_news.oracle.com>
"Laconic2" <laconic2_at_comcast.net> wrote in message
news:nImdncrlS7AQeVPdRVn-ig_at_comcast.com...
>
> "--CELKO--" <jcelko212_at_earthlink.net> wrote in message
> news:18c7b3c2.0406141957.29e933ea_at_posting.google.com...
> > One problem here is that COUNT(*) is CARDINALITY of the set qua set,
> > while COUNT([DISTINCT] <exp>) is at the element level inside the set.
> > Maybe we should have made the syntax: "CARDINALITY(<table
> > expression>)" so you'd know the level that the operatgor is working
> > at.
>
> Speaking of that, I've seen several examples where the writer puts
>
> SELECT COUNT(1) FROM source WHERE (predicate);
>
> I've always wondered whether there are any consequences to that usage,
other
> than readability?
COUNT operator is redundant anyway. Everything could be done with SUM and proper view inlining. In fact SUM fits more naturally in the example above. "COUNT DISTINCT empno" is equivalent to
select SUM(1) from (
select distinct empno from emp
)
Received on Tue Jun 15 2004 - 17:44:07 CEST