jonny jonny - 1 year ago 142
SQL Question

Oracle number to char leading 0

I have a function that calculates number of days
select (x * 0,5) from dual.
my problem is tha when x=1 i get .5 instead of 0,5.What i want to get is numbers in format 0.5,1,1.5,2,2.5 ..
Could you please give me a help with this.

Answer Source

Try to use:

select TO_CHAR(x * 0,5, '990,99') from dual


Try to create a function like this:

create function getDecimalFormat(x in number) 
    return varchar2
    return RTRIM(TO_CHAR(x, 'FM999999999999990.99'), '.');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download