Conversion of a number field in oracle sql


I am having a field which is a number(4) and it has values like

I want it to be converted to

Can this be done.

Please let me know.

Aravindan GPAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Christoffer SwanströmPartnerCommented:
What exactly would the logic for the conversion be? Take the first two digits, then add a colon and after the colon all the remaining digits (fill with zeros)?

For the logic above, do something like this:

      ,CASE WHEN nbr < 0 THEN '-' ELSE '' END || SUBSTR(TO_CHAR(ABS(nbr)), 1, 2) || ':' || NVL(SUBSTR(TO_CHAR(ABS(nbr)), 3, 1), 0) || NVL(SUBSTR(TO_CHAR(ABS(nbr)), 4, 1), 0) AS nbr2
(SELECT 50 AS nbr FROM dual


SELECT -6000 AS nbr FROM dual


SELECT -44 AS nbr FROM dual


SELECT -56 AS nbr FROM dual
) asd

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
select to_char(column,'999,999,999,990.00') from table
Aravindan GPAuthor Commented:
@ bawer this won't work out.
as it will give -6000:00 , 5000:00
I need -60:00 for 6000 and 50:00 for 5000

@tosse I have many values in that table, i gave 4 values as an example..
how to change your query in that case?
Aravindan GPAuthor Commented:
@ tosse I found the way from your query, thanks.
Aravindan GPAuthor Commented:
Thank you :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.