Hi Folks
I have, suppose, three tables with same schema with data for different quarters, and I have to take sum of one of the columns in all three tables and I am sending the following query which returns 3 sums from 3 tables I am looking for a way to get a total of these 3 sums as one amount with just one query, creating a view/temp table is out of question, because table names could be different depending on the date range the data is requested for :
select sum(col1) from table1
union
select sum(col1) from table2
union
select sum(col1) from table3;
is there a way I can do it with just one query, I am willing to consider creating a PL/PGSQL function to do it, if someone can show me how - thanks
Brenda
I have, suppose, three tables with same schema with data for different quarters, and I have to take sum of one of the columns in all three tables and I am sending the following query which returns 3 sums from 3 tables I am looking for a way to get a total of these 3 sums as one amount with just one query, creating a view/temp table is out of question, because table names could be different depending on the date range the data is requested for :
select sum(col1) from table1
union
select sum(col1) from table2
union
select sum(col1) from table3;
is there a way I can do it with just one query, I am willing to consider creating a PL/PGSQL function to do it, if someone can show me how - thanks
Brenda