SQL SERVER AGGREGATE FLOAT VALUES

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
 1056  View(s)
Ratings:
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! 
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: sql server aggregate float values

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!