Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL query

Author  Topic 

asadlone
Starting Member

1 Post

Posted - 2008-06-09 : 05:24:01
Hi all,

I need to combine the accumulate result for the below 4 queries in a single query... how can we achieve that.

Select count(*) from `TelsisStatistics`.`2008060600Events`;
Select count(*) from `TelsisStatistics`.`2008060606Events`;
Select count(*) from `TelsisStatistics`.`2008060612Events`;
Select count(*) from `TelsisStatistics`.`2008060618Events`;

basically its a transformation of 4 queries in to 1 ... while adding the result of all four in the process.

thanks

BR/Asad

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-06-09 : 05:37:20
hi pls try this
i think u want sum of all counts then

select sum(d.s) from
(Select count(*) as s from `TelsisStatistics`.`2008060600Events`
union all
Select count(*) as s from `TelsisStatistics`.`2008060606Events`
union all
Select count(*) as s from `TelsisStatistics`.`2008060612Events`
union all
Select count(*) as s from `TelsisStatistics`.`2008060618Events`
)d


ok tanx...
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-06-09 : 08:00:25
The real question is why you need a new table every day and every 6 hours?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-09 : 15:49:40
quote:
Originally posted by asadlone

Hi all,

I need to combine the accumulate result for the below 4 queries in a single query... how can we achieve that.

Select count(*) from `TelsisStatistics`.`2008060600Events`;
Select count(*) from `TelsisStatistics`.`2008060606Events`;
Select count(*) from `TelsisStatistics`.`2008060612Events`;
Select count(*) from `TelsisStatistics`.`2008060618Events`;

basically its a transformation of 4 queries in to 1 ... while adding the result of all four in the process.

thanks

BR/Asad


Are you using MS SQL Server or MySQL?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -