Home > DeveloperSection > Forums > sql server aggregate float values
Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    May-08-2013 1:09 AM

 MSSQL Server MSSQL Server 

 1 Reply(s)
 758  View(s)
Rate this:
Hi Everyone!

How to get aggregate float values in sql server 2008. I'm try as following

declare @cy datetime
set @d = '12/01/2010'

select SUM(total) from (
select sum(amt1) as total from table1
where date1 < @d  
union all
select sum(amt1) as total from table1
where date1 >= @d
) as a 

thank in advance! 


Total Post:604

Posted on    May-08-2013 8:16 AM

Hi Ankita!

I suspect you are using UNION because there are actually two different tables in your queries, e.g., table1 and table2. In that case, you should not expect the sum to be the same when the date changes.

Update: I just noticed that you are selecting amt in one query and amt1 in the other, so there is no reason to expect the sums to be the same as the date changes.

Don't want to miss updates? Please click the below button!

Follow MindStick