Saturday, May 17, 2008

Split Column

Old method.

SQL> select name from test;
NAME

------------------------------
MOHAMMAD TAJ
BABU B
NIVEDITA SHARMA
RASHIDA BASTAWALA
RADO DENISA

SQL> column firstname format a15
SQL> column lastname format a15

SQL> select
2 substr(name,1,instr(name,' ' )-1) as firstname,
3 substr(name, instr(name,' ',-1)+1) as lastname
4 from test;

FIRSTNAME LASTNAME
--------------- ---------------
MOHAMMAD TAJ
BABU B
NIVEDITA SHARMA
RASHIDA BASTAWALA
RADO DENISA

New Method with 10g or 11g.

Regular Expressions
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28424/adfns_regexp.htm#ADFNS1013

No comments:

Subscribe via email

Enter your email address:

Delivered by FeedBurner