Oracle query to reverse order of First and Last name

I am looking for an Oracle Sql query for following
   I have a table for users and username filed has values  LastName, FirstName (  like Gates, Bill )
   I need to fetch the value as FirstName Name  ( Like Bill Gates)
Sam OZAsked:
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.

select trim(regexp_substr(username,'[^,]+',1,2)) || ' ' || trim(regexp_substr(username,'[^,]+',1,1)) from yourtable

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
Geert GOracle dbaCommented:
i'd use 2 fields (or more) to store that data in ...
Some people have more than 2 names in their name

And if that's stored with multiple ',' ... then even sdstuber's query will not show everything
Mark GeerlingsDatabase AdministratorCommented:
If you prefer to do this with a query that may be easier to understand (but may be not quite as efficient as sdstuber's) you could use a combination of the Oracle "substr" (sub-string ) and "instr" (in-string) operators like this:

select trim(substr(username,instr(username,',') +1),' ') ||' '|| substr(username,1, instr(username,',') -1)
from [your_table]
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

From novice to tech pro — start learning today.