Page 1 of 1

Counts of records in Different tables

Posted: Mon Nov 27, 2006 6:55 am
by azeezpasha
Hi friends,

i want to write a query to find the total count of records in two tables,
say emp,dept

and the desired out put should be like follows

count(emp.DEPTNO) count(Dept.Deptno)
14 4

but i am getting different result like follows

count(emp.DEPTNO) count(Dept.Deptno)
14 14

can any body tell me how to get the desired result.

its very very urgent

Thanks in advance.

Regards,
Azeez
azeezmsc@gmail.com

Posted: Mon Nov 27, 2006 7:52 am
by admin
SQL> select
2 (select count(*) from emp) emp_cnt,
3 (select count(*) from dept) dept_cnt
4 from dual;

EMP_CNT DEPT_CNT
--------- ---------
14 4
or

SQL> select
2 (select count(*) from emp) || ',' || (select count(*) from dept) "Emp-Dept"
3 from dual
4 /

Emp-Dept
---------------------------------------------------------------------------------
14,4

Posted: Mon Nov 27, 2006 9:29 am
by azeezpasha
[quote]SQL> select
2 (select count(*) from emp) emp_cnt,
3 (select count(*) from dept) dept_cnt
4 from dual;

EMP_CNT DEPT_CNT
--------- ---------
14 4
or

SQL> select
2 (select count(*) from emp) || ',' || (select count(*) from dept) "Emp-Dept"
3 from dual
4 /

Emp-Dept
---------------------------------------------------------------------------------
14,4


<i><div align="right">Originally posted by admin

Posted: Sat Dec 09, 2006 5:54 am
by punithavel
Thanks.. it is looking very nice

Posted: Fri Feb 23, 2007 7:08 am
by srinu_a47
[quote]Thanks.. it is looking very nice

<i><div align="right">Originally posted by punithavel

Posted: Fri Feb 23, 2007 7:10 am
by srinu_a47
select count(*) from emp
union all
select count(*) from dept;

the output is
COUNT(*)
---------
14
4

Posted: Sat Feb 24, 2007 9:00 pm
by amirtai
Hello

Can I get table wise record count of a schema. Like I need record count of all SCOTT tables from user_tables. Instead of mentioning name of tables explicitly?