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!

Query with JOIN to Format phone number to (xxx)xxx-xxxx

User_H76VHAug 12 2016 — edited Aug 12 2016

Hi,

I been trying to figure out how to add to my query to reformat phone number that are stored in the PHONE_VIEW as xxx-xxx-xxxx. I need to reformat to (xxx)xxx-xxxx.

Here is my query so far

select

person.personId,

person.first_name,

person.last_name,

phone.phone_number,

phone.phone_type

from person_view person

left join (select personId, phone_type,

('(' + substr(phone_number,1,3) + ')' + substr(phone_number, 5,3) + '-' + substr(phone_number,9,4)) as phone_number,

from phone_view ) phone

on person.personId = phone.personId and phone.phone_type in ('home', 'work','mobile')

I could not get this to work.

Any help is greatly appreciated. Thanks.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 9 2016
Added on Aug 12 2016
3 comments
1,692 views