Re: COunt problem

Hi,
   if you want try to avoid the cartesian join you could write a query
like the following one:

Connected as test

SQL> create table emp as select * from all_objects where rownum<=3D1234;

Table created

SQL> create table emp_dis as select * from all_objects where rownum<=3D5678=
;

Table created

SQL> select sum(emp_n),sum(emp_dis_n) from (
  2  select decode(t,1,num,0) emp_n,decode(t,2,num,0) emp_dis_n
  3   from (select 1 t,count(*)num from emp
  4   union select 2 t, count(*) num from emp_dis))
  5    ;

SUM(EMP_N) SUM(EMP_DIS_N)
---------- --------------
      1234           5678

Giovanni


On 6/14/05, Kean Jacinta <jacintakean@xxxxxxxxx> wrote:
> Hi ,
>=20
> I am trying to do a count on 2 table at the same time.
>=20
> select count(a.idcode), count(b.idcode)
> from emp a, emp_dis b
>=20
> The result return are not corrent. Both idcode
> datatype is number.
>=20
> Actual table count for emp : 15
> Actual table count for emp_dis :25
>=20
> Thank You
> JK
>=20
>=20
>=20
> __________________________________
> Yahoo! Mail
> Stay connected, organized, and protected. Take the tour:
> http://tour.mail.yahoo.com/mailtour.html
>=20
> --
> http://www.freelists.org/webpage/oracle-l
>=20


--=20
--------------------------------------------------------------------
Another free oracle resource profiler
http://sourceforge.net/projects/oraresprof/
New version 0.8 with many bug fixes
and warnings on file truncated, timed_statistics=3Dfalse, incorrect
tracing deactivation and more
--
http://www.freelists.org/webpage/oracle-l

Other related posts: