Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting a Single count with union all

User_19BPUDec 18 2010 — edited Dec 20 2010
Hi,

Would you please tell me if it is possible to get only one count when using a union all like :-

select count(value_x) from table_a
Where name='BOB'
union all
select count(value_x) from table_b;
Where name='Chris'

Here both the count will return the same value

If I use the below query:-

select cnt
from (select count(value_x) cnt from table_a
UNION ALL
select count(value_x) from table_b
)

I am getting the values for the count (cnt) like 1,2,3,4,5,6,7,8,9,10 instead of

cnt
---
10

But the no. of rows are correct. How to change this?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 17 2011
Added on Dec 18 2010
13 comments
9,536 views