Is there a way to get a total counts from the resultset of two unions? This will be for DB2.

select count(*) from (
select count(*) from xyz where abc='1'
union all
select count(*) from x1y1z1 where abc='1'
)

Recommended Answers

All 2 Replies

Try this:

select sum(items) from 
(
select 1 as items from xyz where abc=1
union
select 1 as items from x1y1z1 where abc - 1
)

kind of old fashioned but it works

That worked. Thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.