Solved

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

Posted on 2013-12-12
4
317 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
  • 2
4 Comments
 
LVL 11

Accepted Solution

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

Assisted Solution

by:Jim Horn
Jim Horn earned 250 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now