Database Administration (MOSC)

MOSC Banner

Displaying Zero

edited Sep 18, 2009 7:00PM in Database Administration (MOSC) 6 commentsAnswered
 Hi,

I need to get the values that retain one zero on the left of the decimal, and dont have any trailing zeroes at the end on right of a decimal?

create table test_num(num number);

insert into test_num values(1);
insert into test_num values(0.7);
insert into test_num values(0.187);
insert into test_num values(1.2);

commit;
select * from test_num;


SQL> select * from test_num;

       NUM
----------
         1
        .7
      .187
       1.2
      
To get the zeroes as needed, I can query as below:

select decode(instr(num,'.'),1,'0'||num,num) from test_num;

DECODE(INSTR(NUM,'.'),1,'0'||NUM,NUM)

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center