When it's a whole numer, just cast it to INT. The CHAR(INT)) does not generate leading zeros. If it is not a whole number then you get ugly code like this:
Code:
select case when TOT_M < 9 then substr(char(TOT_M),09,03)
when TOT_M < 99 then substr(char(TOT_M),08,04)
when TOT_M < 999 then substr(char(TOT_M),07,05)
else char(TOT_M)
end as result
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.