Solved

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

Posted on 2013-11-25
6
954 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
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)

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

12 Experts available now in Live!

Get 1:1 Help Now