Link to home
Start Free TrialLog in
Avatar of Endelm
Endelm

asked on

MSSQL 2005 - Decimal column query

Hi,

select mydecimalcolumn
from mytable

gives me:
10.05
4.25
4.5
4.0

How can I make a query that gives me data having a fracture more than 1 letter
10.05
4.25

Thank you.
Avatar of Jinesh Kamdar
Jinesh Kamdar
Flag of India image

You can convert it into a char and select only those records whose string-length following the decimal point (.) is greater than 1.
ASKER CERTIFIED SOLUTION
Avatar of nicolasdiogo
nicolasdiogo
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this.

select mydecimalcolumn
from mytable
where mydecimalcolumn*10 <> Round(mydecimalcolumn*10,0)
select mydecimalcolumn
from mytable
where (mydecimalcolumn * 100) % 10 <> 0
take that last one back. try this

select mydecimalcolumn
from mytable
where cast(mydecimalcolumn as decimal(10,1) <> mydecimalcolumn)

one op only, which is cast to 1dp, so should be quite fast
Based On Imitchie's code,
select mydecimalcolumn
from mytable
where cast(mydecimalcolumn as decimal(10,1) < mydecimalcolumn)

Open in new window

sorry the mistake. i am take back my post
Avatar of ursangel
ursangel

select mydecimalcolumn from Mytable
where len(mydecimalcolumn) - charindex('.', mydecimalcolumn) >= 2