Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: select count(*)
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);
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