?
Solved

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

Posted on 2013-12-12
4
Medium Priority
?
324 Views
Last Modified: 2013-12-12
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
Comment
Question by:rhservan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Simone B earned 1000 total points
ID: 39714720
Your query is correct. Do you only have 10 rows in your table?
0
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 1000 total points
ID: 39714728
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
 

Author Comment

by:rhservan
ID: 39714905
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
 
LVL 11

Expert Comment

by:Simone B
ID: 39715283
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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question