Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sort out specific float values

Author  Topic 

mauich123
Starting Member

21 Posts

Posted - 2011-02-01 : 04:11:18
Using a WHERE clause, how can I sort out float values ending with .01 ?
I've tried to do it using LIKE but with no success.

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-01 : 04:13:42
check if this works for you ...

Where rtrim(str(FloatColumnName)) like '%.01'

Cheers!
MIK
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-02-01 : 04:29:08
where right(YourColumn,3) = '.01'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

mauich123
Starting Member

21 Posts

Posted - 2011-02-01 : 04:29:40
Hi MIK,
No, doesnt seem to work. I also checked

select rtrim(str(total)) from table1

but it just removes the comma sign so I can't use it in my where-clause
Go to Top of Page

mauich123
Starting Member

21 Posts

Posted - 2011-02-01 : 04:30:45
quote:
Originally posted by webfred

where right(YourColumn,3) = '.01'


No, you're never too old to Yak'n'Roll if you're too young to die.



This worked, thanks!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-02-01 : 04:35:37
Oh man... FLOAT datatypes can be "73.010000000000000001" due to the way FLOAT is implemented from IE884.

Use this

WHERE Col1 LIKE '%[,.]01%' because you cannot be sure the decimal sign is what you expect.
See http://weblogs.sqlteam.com/peterl/archive/2011/01/14/some-datatypes-doesnt-honor-localization.aspx



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

mauich123
Starting Member

21 Posts

Posted - 2011-02-01 : 04:37:32
quote:
Originally posted by Peso

Oh man... FLOAT datatypes can be "73.010000000000000001" due to the way FLOAT is implemented from IE884.

Use this

WHERE Col1 LIKE '%[,.]01%' because you cannot be sure the decimal sign is what you expect.
See http://weblogs.sqlteam.com/peterl/archive/2011/01/14/some-datatypes-doesnt-honor-localization.aspx



N 56°04'39.26"
E 12°55'05.63"




Okay I see your point, but these values are deliberately set to .01 and the above "right(YourColumn,3) = '.01'" worked for my table where it's actually "," also.
Go to Top of Page
   

- Advertisement -