Q:

Formatting String out from Oracle Select Query

Lets say when I run the following query,
SELECT NAME 
  FROM EMP;

It return the following 2 rows.
NAME
------------
Jan Jones
Arne Barnie

But I wanted it in the following format  
J. Jones
A. Barnie

How I can get that?

A:

It should be possible with regexp_replace:
with names as (
  select 'Jan Jones'   name from dual union all
  select 'Arne Barnie' name from dual
)
select
  regexp_replace(name, '(.)[[:alpha:]]* *([[:alpha:]]*)', '\1. \2') name
from
  names;

Alternatively, if you prefer the \X notation over the [[:...:]] notation, you can use
regexp_replace(name, '(.)\w* *(\w*)', '\1. \2') 

