Patrick Bateman
Patrick Bateman

Reputation: 271

Oracle SQL: Inserting a decimal into a specific location in an int

This seems like a very straightforward question but for some reason my mind is not there:

I am loading numbers into an oracle db. They are n digits in length and are all whole numbers i.e. 38495. I know from the file format that this number does not represent 38495 but instead 384.95

How to I insert the decimal two digits to the left of the right most digit?

When I do this:

select to_char(to_number('38495'),'999.99') from dual;

My result is this:

#######

Do I really need to substring this value? It seems like there should be a more elegant solution.

Upvotes: 1

Views: 1561

Answers (1)

JSR
JSR

Reputation: 6396

Divide the whole number by 100.0

Upvotes: 1

Related Questions