• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

SUM is incorrect when performing on Float column in DB, How can I fix this?

Current:
FloatCol with float for datatype
SumofFloatCol

Sum of Float Col is way off how can I sum this column with the values in floatCol

FloatCol
102.8
22.8
68.3
656.2
755.4
382.8
736.5
728.9
163.9
0.1

SumOfFloatCol
139608.36
Using this query
SELECT sum(FloatCol)
From Table1
0
rhservan
Asked:
rhservan
  • 2
2 Solutions
 
Simone BCommented:
Your query is correct. Do you only have 10 rows in your table?
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Just for kicks and giggles, do a 'SELECT * FROM Table1' and verify that there are only 10 rows in it, with floatcol values as you posted above.
0
 
rhservanAuthor Commented:
So I take it the SUM aspect works the same on float as SUM on any other legitimate datatype.

1+1=2. I thought maybe float was not working correctly with SUM.    I get this.
--------------------------------------------------------------------------------------------------------------------------------

So using another scenario in an SSRS column in a Tablix:

Col_1
102.8
22.8
68.3
656.2
755.4
382.8
736.5
728.9
163.9
0.1

how would I SUM this column in the last row.

Currently Using this query
SELECT sum(FloatCol)
From Table1  
Seems to give me the total of all the rows, about 85,000,  instead of just the rows returned from the query which is somewhere like 3,600.
0
 
Simone BCommented:
Use the same field, and just put it in the summary row. It will do the sum for you automatically. You don't have to have a separate query.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now