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!

Oracle SQL query. How to obtain string tokens from a string using 'space' as a delimiter, then displ

MJasonMSep 12 2018 — edited Sep 12 2018

E.g. I have a table - USERS, with column NAME1 varchar2(30). Records currently in it are:

NAME1: 
Benjamin Barker
Alexis Jacob Alexander Cruise
Christopher James Lee

How do I create a function or write a query where I can get the output as follows:

Benjamin **** 
Alexis
**** Cruise
Christopher
**** Lee

The function/query will calculate the name string and return E.g. 'Benjamin barker' as 2 tokens, but only display the first token. While if the name has three or more tokens, e.g. 'Christopher James Lee' or 'Alexis Jacob Alexander Cruise', it will only display the first and the last token.

This post has been answered by mathguy on Sep 12 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 10 2018
Added on Sep 12 2018
6 comments
4,255 views