Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SELECT COUNT(*) FROM TABLE query problem
"Harry Sheng" <hsheng_at_innovance.com> wrote in message news:<hHBp9.15301$H67.69008_at_tor-nn1.netcom.ca>...
> select sum(cnt)
> from (select count(*) cnt from table1
> union
> select count(*) cnt from table2
> )
>
> "Monty" <mmontreaux_at_hotmail.com> wrote in message
> news:6284dd3.0210110547.61cfcd4c_at_posting.google.com...
> > Hi there - the following hypothetical query is what I want but I can't
> > figure out how to correctly formulate it (actually the real query is
> > significantly more complex but the underlying problem with it
> > expressed in the query below. Furthermore I don't want to have to
> > perform two queries to resolve my problem).
> >
> > Basically I'm wanting to retrieve the total number
> >
> > Ideas anyone?
> >
> > Monty
> >
> > SELECT t1.COUNT(*), t2.COUNT(*)
> > FROM tablename1 t1, tablename2 t2;
If I undersod it rigth, you would like to have the count from bouth the tables in two columns in the same row.
Somthin like this would do the trick:
select sum(count_table1) , sum(count_table2) from ( select count(rowid) , 0
from tablename1 union select 0 , count(rowid) from tablename2 );Received on Fri Oct 11 2002 - 15:27:01 CDT