Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 5 of 5 total |
SQL Question? No error - wrong result? |
Mon, Sep 24 2007 3:22 AM | Permanent Link |
Dave Bailey | Hi,
I have a table with 4 Float Fields eg: a,b,c,d d is entered by the user but is the result of a+b+c I wanted to create an SQL to filter out all records where d<>a+b+c I used SELECT * FROM MyTable WHERE (a+b+c)<>d But the result included records where a+b+c=d as well? Tested the same on Access and no problem. Maybe it is something I am doing wrong? Thanks |
Mon, Sep 24 2007 4:06 AM | Permanent Link |
Eryk Bottomley | Dave,
> I have a table with 4 Float Fields eg: a,b,c,d > > d is entered by the user but is the result of a+b+c > > I wanted to create an SQL to filter out all records where d<>a+b+c > > I used SELECT * FROM MyTable WHERE (a+b+c)<>d Never use direct equality tests on floats like that. > But the result included records where a+b+c=d as well? Try "WHERE ABS((a+b+c)-d) > 0.01" ...or whatever level of precision makes sense in the context of your app. Eryk PS: You might want to read up on BCD fields - they may be more appropriate than floats if you are doing stuff like this. |
Mon, Sep 24 2007 4:08 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Dave
Float fields are notorious for this. Its a case of what you see is not necessarily what you get You'll need to round each field in some way. Then again Tim may need to make sure the results for a float field are only returned to the precision specified. I'm not sure which it should be in ElevateDB, in DBISAM it was definitely your responsibility. Roy Lambert |
Mon, Sep 24 2007 6:42 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< Float fields are notorious for this. Its a case of what you see is not necessarily what you get You'll need to round each field in some way. Then again Tim may need to make sure the results for a float field are only returned to the precision specified. I'm not sure which it should be in ElevateDB, in DBISAM it was definitely your responsibility. >> ElevateDB is the same as DBISAM in this regard. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Sep 24 2007 6:43 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Eryk,
<< PS: You might want to read up on BCD fields - they may be more appropriate than floats if you are doing stuff like this. >> DECIMAL is the proper term with ElevateDB. http://www.elevatesoft.com/edb1sql_exact_numeric_types.htm -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |