?
Solved

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

Posted on 2013-11-25
6
Medium Priority
?
1,161 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
[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
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
How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

 
LVL 10

Expert Comment

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

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

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.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

762 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