Sum with Negative and Positive Numbers - Sql Server [closed]

0

I'm trying to do the sum of positive and negative values in the SqlServer database, but the same thing done by the calculator returns a different value.

I'm using

SUM(NR_QUANTIDADE) 

The NR_QUANTITY column is of type float in the database.

My values in the database are:

-9,9961
-30,41
-19,5939
60

The result of my select is already returning:

-5,32907051820075E-15

And the right thing would be to return 0.

    
asked by anonymous 04.05.2018 / 14:32

1 answer

0

I built an example based on what you posted:

create table temp (valor float)

insert into temp (valor) values (-9.9961)
insert into temp (valor) values (-30.41)
insert into temp (valor) values (-19.5939)
insert into temp (valor) values (60)

select sum(valor) total from temp

SQL Fiddle: link

    
04.05.2018 / 14:42