Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: The use of COUNT(*)

Re: The use of COUNT(*)

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Fri, 10 Jul 1998 18:49:43 GMT
Message-ID: <35b061c7.21415423@192.86.155.100>


A copy of this was sent to doid <doid_at_usa.net> (if that email address didn't require changing) On Fri, 10 Jul 1998 18:04:00 GMT, you wrote:

>Been there:)
>
>1) count(*) won't count nulls. this can screw up your logic
>sometimes...anyway, it's much more efficent to count( <some indexed column> )
>or count(1)
>

no thats backwards, count(*) counts nulls -- its count(<some indexed column>) -- actually count(any column) -- that won't.....

SQL> create table demo ( x int );
Table created.

SQL> create index demo_x_idx on demo(x); Index created.

SQL> insert into demo values ( null );
1 row created.

SQL> select count(*) from demo;

  COUNT(*)


         1

SQL> select count(x) from demo;

  COUNT(X)


         0

[snip]
>
>doid
>
>
>
>
>Lai King Leung wrote:
>
>> Could anyone tell me about the use of COUNT(*)?
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA  

http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Fri Jul 10 1998 - 13:49:43 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US