Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to get negative sign for amount

Rajesh123Apr 5 2016 — edited Apr 5 2016

Hi all,

select '387.22' EXTENDED_AMOUNT  from dual

union all

select '309.62' EXTENDED_AMOUNT  from dual

union all

select '       (1,389.00)' EXTENDED_AMOUNT  from dual

union all

select '         (138.90)' EXTENDED_AMOUNT  from dual

union all

select '       (5,972.70)' EXTENDED_AMOUNT  from dual

I have used below code to get output with negative sign

select LTRIM(rtrim(trim(EXTENDED_AMOUNT),')'),'(')*-1

from dual;

output:

-387.22

-309.62

-138.90

Expected output is:

-387.22

-309.62

-1,389.00

-138.90

-5,972.70

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 3 2016
Added on Apr 5 2016
20 comments
8,259 views