Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1054861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:28:22+00:00 2026-05-16T17:28:22+00:00

I have an sql: SELECT Sum(Field1), Sum(Field2), Sum(Field1)+Sum(Field2) FROM Table GROUP BY DateField HAVING

  • 0

I have an sql:

SELECT Sum(Field1), Sum(Field2), Sum(Field1)+Sum(Field2)
FROM Table
GROUP BY DateField
HAVING Sum(Field1)+Sum(Field2)<>0;

Problem is sometimes Sum of field1 and field2 is value like: 9.5-10.3 and the result is -0,800000000000001. Could anybody explain why this happens and how to solve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:28:23+00:00Added an answer on May 16, 2026 at 5:28 pm

    I’m certain it is because the float data type (aka Double or Single in MS Access) is inexact. It is not like decimal which is a simple value scaled by a power of 10. If I’m remembering correctly, float values can have different denominators which means that they don’t always convert back to base 10 exactly.

    The cure is to change Field1 and Field2 from float/single/double to decimal or currency. If you give examples of the smallest and largest values you need to store, including the smallest and largest fractions needed such as 0.0001 or 0.9999, we can possibly advise you better.

    Be aware that versions of Access before 2007 can have problems with ORDER BY on decimal values. Please read the comments on this post for some more perspective on this. In many cases, this would not be an issue for people, but in other cases it might be.

    In general, float should be used for values that can end up being extremely small or large (smaller or larger than a decimal can hold). You need to understand that float maintains more accurate scale at the cost of some precision. That is, a decimal will overflow or underflow where a float can just keep on going. But the float only has a limited number of significant digits, whereas a decimal’s digits are all significant.

    If you can’t change the column types, then in the meantime you can work around the problem by rounding your final calculation. Don’t round until the very last possible moment.

    Update

    A criticism of my recommendation to use decimal has been leveled, not the point about unexpected ORDER BY results, but that float is overall more accurate with the same number of bits.

    No contest to this fact. However, I think it is more common for people to be working with values that are in fact counted or are expected to be expressed in base ten. I see questions over and over in forums about what’s wrong with their floating-point data types, and I don’t see these same questions about decimal. That means to me that people should start off with decimal, and when they’re ready for the leap to how and when to use float they can study up on it and start using it when they’re competent.

    In the meantime, while it may be a tad frustrating to have people always recommending decimal when you know it’s not as accurate, don’t let yourself get divorced from the real world where having more familiar rounding errors at the expense of very slightly reduced accuracy is of value.

    Let me point out to my detractors that the example

    Decimal(1) / 3 * 3 yielding 1.999999999999999999999999999

    is, in what should be familiar words, “correct to 27 significant digits” which is “correct for all practical purposes.”

    So if we have two ways of doing what is practically speaking the same thing, and both of them can represent numbers very precisely out to a ludicrous number of significant digits, and both require rounding but one of them has markedly more familiar rounding errors than the other, I can’t accept that recommending the more familiar one is in any way bad. What is a beginner to make of a system that can perform a - a and not get 0 as an answer? He’s going to get confusion, and be stopped in his work while he tries to fathom it. Then he’ll go ask for help on a message board, and get told the pat answer “use decimal”. Then he’ll be just fine for five more years, until he has grown enough to get curious one day and finally studies and really grasps what float is doing and becomes able to use it properly.

    That said, in the final analysis I have to say that slamming me for recommending decimal seems just a little bit off in outer space.

    Last, I would like to point out that the following statement is not strictly true, since it overgeneralizes:

    The float and double types store numbers in base 2, not in base 10.

    To be accurate, most modern systems store floating-point data types with a base of 2. But not all! Some use or have used base 10. For all I know, there are systems which use base 3 which is closer to e and thus has a more optimal radix economy than base 2 representations (as if that really mattered to 99.999% of all computer users). Additionally, saying “float and double types” could be a little misleading, since double IS float, but float isn’t double. Float is short for floating-point, but Single and Double are float(ing point) subtypes which connote the total precision available. There are also the Single-Extended and Double-Extended floating point data types.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with an SQL query. SELECT SUM(table_colum) AS value, SUM(value *
i have this sql query select * from table where name like ? but
I have following SQL statementL: select DATE(bla), count(*) from tableA group by DATE(bla) UNION
I have the following SQL: SELECT ( (SELECT SUM(vote_score) FROM question_votes JOIN questions ON
I have a simple SQL query: Select ID, COUNT(ID) as Selections, OptionName, SUM(Units) as
i have sql query select * from Roles Join Users On Roles.Role=Users.RoleId it return
I have this SQL statement: SELECT * FROM history WHERE (fk_person = 2119) AND
I have an SQL statement: SELECT * FROM customers WHERE BINARY login='xxx' AND password='yyyy'
I have the following SQL: SELECT * FROM [Database].dbo.[TagsPerItem] INNER JOIN [Database].dbo.[Tag] ON [Tag].Id
I have three tables in sql, CUSTOMER, ISSUE, ISSUE_NOTES. SELECT CUSTOMER.name, ISSUE.description, ISSUE_NOTES.notes FROM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.