Solved

How can I get the mantissa (integer) portion of a decimal in sql

Posted on 2013-11-25
6
980 Views
Last Modified: 2013-11-29
If I have decimal 123456789.456789

How can I get the 123456789 portion of it.
0
Comment
Question by:countrymeister
6 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39675576
Just cast it as an integer..
SELECT CAST(123456789.456789 as int) 

Open in new window

0
 
LVL 10

Expert Comment

by:GeoffSutton
ID: 39675600
or use the TQSL round:  select round(123456789.456789,0) as result
0
 
LVL 5

Expert Comment

by:Lawrence Barnes
ID: 39675628
Or if you don't want it to round and just want to drop it use this version ofTSQL Round:

SELECT ROUND(123456789.456789, 0, 1) as RoundWithZero
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 10

Expert Comment

by:GeoffSutton
ID: 39675659
Thanks for filling that in, Ivbarnes.  Missed it :)
0
 
LVL 69

Accepted Solution

by:
ScottPletcher earned 300 total points
ID: 39675827
If you want to truncate, so that 12.99999 became 12, you could also do:

FLOOR(decimal_column)

If you always wanted to round up, so that 12.05 became 13, you could do:

CEILING(decimal_column)
0
 
LVL 5

Expert Comment

by:Lawrence Barnes
ID: 39675843
Huzzah Scott!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now