• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • 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 BSenior E-Commerce AnalystCommented:
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 BSenior E-Commerce AnalystCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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