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!

Number Format using SUBSTR

srikanth bDec 18 2021

create table test(phone_num) as
(
select '8297231486' from dual union all
select '900005452' from dual
)
Expected result:
(829) 723-1486
(900) 005-4527

My effort
select concat('(',substr(phonenum,1,3),')',substr(phonenum,4,3),'-',substr(phonenum,7) as num_formatted from test

This post has been answered by mathguy on Dec 18 2021
Jump to Answer
Comments
Post Details
Added on Dec 18 2021
9 comments
2,117 views