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

Home -> Community -> Usenet -> c.d.o.misc -> Re: select count(*)

Re: select count(*)

From: Martin Douglas <Martin.Douglas_at_Boeing.com>
Date: 1999/08/10
Message-ID: <37B032C7.B4E4A0A4@Boeing.com>#1/1

Consider the following:

#1

create table table1(col1 number, col2 number);

insert into table1 values(1, 1);
insert into table1 values(2, 2);
insert into table1 values(3, 3);

commit;

select col1, col2, count(*) as total_record from table1
group by col1, col2;

COL1 COL2 TOTAL_RECORD
------------ ------------ ------------

           1            1            1
           2            2            1
           3            3            1

not what you want... the next example is however

#2

select col1, col2, total_record
from table1, (select count(*) as total_record from table1);

COL1 COL2 TOTAL_RECORD
------------ ------------ ------------

           1            1            3
           2            2            3
           3            3            3

rely on Catesian cross product

-Martin-

Norris wrote:
>
> In SQL Server, I can do the following queries:
>
> select col1, col2, count(*) total_record
> from table1
>
> select col1, col2, (select count(*) from table1) total_record
> from table1
>
> In Oracle, how can I do that?
>
> --
> ---
> http://www.washington.edu/pine/faq/
Received on Tue Aug 10 1999 - 00:00:00 CDT

Original text of this message

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