Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi Can we write a SQL which give

Status
Not open for further replies.

nkm

Programmer
May 27, 2001
45
US
Hi

Can we write a SQL which gives the sum of the counts of 2 individual tables combined with a union clause

Basically

select count(*) from tmp union all select count(*) from tmp1

This will return 2 rows I want the sum of the values of the two rows.

regards


 
Hi:

One possible solution is to select into a temp table and then count the rows in the temp:

select cols from tmp union all select cols from tmp1
into temp c;
select count(*) from c;
drop table c;

"cols" is a column in the two tables tmp and tmp1. Informix does NOT allow this:

select count(*) from tmp union all select count(*) from tmp1
into temp c;

Regards,


Ed
 
select count(*) from c;

OR

select sum(cols) from c;

Plz advice

rgds
Schill
 
Hi:

I interpret the question to be "how many rows", so it's

select count(*) from c

Regards,

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top