jonny jonny - 6 months ago 19
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

Try to use:

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

EDIT:

Try to create a function like this:

create function getDecimalFormat(x in number) 
    return varchar2
as
begin
    return RTRIM(TO_CHAR(x, 'FM999999999999990.99'), '.');
end;