Counts of records in Different tables

In this forum you can share stuff related to Oracle 11g, 10g, 9i.
Post Reply
azeezpasha
Posts: 26
Joined: Fri Nov 10, 2006 3:15 am
Location: India

Counts of records in Different tables

Post 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
admin
Posts: 2063
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

Post 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
azeezpasha
Posts: 26
Joined: Fri Nov 10, 2006 3:15 am
Location: India

Post 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
punithavel
Posts: 4
Joined: Wed Nov 08, 2006 6:15 am
Location: India

Post by punithavel »

Thanks.. it is looking very nice
srinu_a47
Posts: 16
Joined: Fri Feb 23, 2007 7:02 am
Location: India

Post by srinu_a47 »

[quote]Thanks.. it is looking very nice

<i><div align="right">Originally posted by punithavel
srinu_a47
Posts: 16
Joined: Fri Feb 23, 2007 7:02 am
Location: India

Post by srinu_a47 »

select count(*) from emp
union all
select count(*) from dept;

the output is
COUNT(*)
---------
14
4
amirtai
Posts: 138
Joined: Sat Apr 08, 2006 5:54 pm
Location: Canada
Contact:

Post 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?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest