?
Solved

MSSQL 2005 - Decimal column query

Posted on 2007-12-04
8
Medium Priority
?
794 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:Endelm
8 Comments
 
LVL 18

Expert Comment

by:Jinesh Kamdar
ID: 20401905
You can convert it into a char and select only those records whose string-length following the decimal point (.) is greater than 1.
0
 
LVL 5

Accepted Solution

by:
nicolasdiogo earned 2000 total points
ID: 20401907
you can use a convert statement for that:


declare @d decimal(10,6)

set @d = 13.2452435


select @d
select convert( decimal (10, 2), @d )
0
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 20401920
Try this.

select mydecimalcolumn
from mytable
where mydecimalcolumn*10 <> Round(mydecimalcolumn*10,0)
0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
LVL 25

Expert Comment

by:imitchie
ID: 20401938
select mydecimalcolumn
from mytable
where (mydecimalcolumn * 100) % 10 <> 0
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20401942
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
0
 
LVL 6

Expert Comment

by:Rajesh_mj
ID: 20401973
Based On Imitchie's code,
select mydecimalcolumn
from mytable
where cast(mydecimalcolumn as decimal(10,1) < mydecimalcolumn)

Open in new window

0
 
LVL 6

Expert Comment

by:Rajesh_mj
ID: 20401984
sorry the mistake. i am take back my post
0
 
LVL 5

Expert Comment

by:ursangel
ID: 20410157
select mydecimalcolumn from Mytable
where len(mydecimalcolumn) - charindex('.', mydecimalcolumn) >= 2
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

840 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