?
Solved

MSSQL 2005 - Decimal column query

Posted on 2007-12-04
8
Medium Priority
?
791 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 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