Home » SQL & PL/SQL » SQL & PL/SQL » rounding to decimal places
rounding to decimal places [message #193961] Wed, 20 September 2006 02:41 Go to next message
monasingh
Messages: 229
Registered: May 2006
Location: Mumbai
Senior Member

Hi,
I have to round a numeric column to 4 decimal places. I have to display the 4 decimal places even if it is zero.
SELECT ROUND(146111.023032,4) from dual;
146111.023

This should have given : 146111.0230

select round(12345.0000040,4) from dual;
12345

This should have given 12345.0000

Please advice.

Thanks,
Mona
Re: rounding to decimal places [message #193962 is a reply to message #193961] Wed, 20 September 2006 02:43 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
If you want to have trailing or leading zeros on a number, you need to convert it to a char string.
Re: rounding to decimal places [message #193977 is a reply to message #193962] Wed, 20 September 2006 04:24 Go to previous messageGo to next message
monasingh
Messages: 229
Registered: May 2006
Location: Mumbai
Senior Member

Thanks JRow.

Regards,
Mona
Re: rounding to decimal places [message #194038 is a reply to message #193977] Wed, 20 September 2006 09:04 Go to previous messageGo to next message
shoblock
Messages: 325
Registered: April 2004
Senior Member
if using sqlplus, just use a COLUMN FORMAT command

column x format 99999999990.9999
SELECT ROUND(146111.023032,4) x from dual;

X
-----------------
146111.0230
Re: rounding to decimal places [message #194133 is a reply to message #194038] Wed, 20 September 2006 22:48 Go to previous message
monasingh
Messages: 229
Registered: May 2006
Location: Mumbai
Senior Member

Thanks shoblock,
This is a good idea.

Regards,
Mona
Previous Topic: declaring variables in a script
Next Topic: How to prepare a script for delivery
Goto Forum:
  


Current Time: Mon Dec 05 08:37:13 CST 2016

Total time taken to generate the page: 0.06187 seconds