[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2013-11-25
6
Medium Priority
?
1,267 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 66

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
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.

 
LVL 10

Expert Comment

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

Accepted Solution

by:
Scott Pletcher earned 1200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

872 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