Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on How To get First,middle and last name from a column? within the Oracle forums, part of the Databases category; Hi friends, i have one problam,please give me the solution. I have column in a with name.now i want to select that names as first name,second name,third name. I/p---- names ...
|
|||||||
| Oracle Oracle 9i & Oracle 10g Knowledge Base Learn and Share Oracle Technology related articles, white papers, tutorials / study materials, example codes, FAQ's, Tips and Tricks. |
![]() |
| LinkBack | Thread Tools | Display Modes |
|
|||
|
How To get First,middle and last name from a column?
Hi friends, i have one problam,please give me the solution. I have column in a with name.now i want to select that names as first name,second name,third name. I/p---- names chandra sekhar balaji. Giri koti reddy nagendra lakshman bala now i want o/p like. Firstname secondname thirdname chandra sekhar balaji giri koti reddy nagendra lakshman bala
|
| Sponsored Links |
|
|||
|
Re: How To get First,middle and last name from a column?
Here is the query
SQL> SELECT substr(name,1,instr(name,' ',1,1)-1) Firstname, substr(name,instr(name,' ',1,1)+1,(instr(name,' ',1,2)-instr(name,' ',1,1))-1) Middlename, substr(name,instr(name,' ',1,2)+1) Lastname FROM test; FIRSTNAME MIDDLENAME LASTNAME ------------------------------ ------------------------------ ------------------------------ chandra sekhar balaji Giri koti reddy nagendra lakshman bala SQL> |
| The Following User Says Thank You to krishnaindia2007 For This Useful Post: | ||
|
|||
|
Re: How To get First,middle and last name from a column?
Select substr('giri koti reddy nagendra lakshman bala',1, instr('giri koti reddy nagendra lakshman bala',' ',1)) first_name, substr('giri koti reddy nagendra lakshman bala',instr('giri koti reddy nagendra lakshman bala',' ',1)+1, instr('giri koti reddy nagendra lakshman bala',' ',2)) middle_name, substr('giri koti reddy nagendra lakshman bala',instr('giri koti reddy nagendra lakshman bala',' ',-2)+1, instr('giri koti reddy nagendra lakshman bala',' ',-1)) last_name from dual
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Insert new column in the middle of a table | Geek_Guest | SQL | 20 | 12-06-2008 11:23 AM |
| Inserting column in the middle | mohdfarezpink | SQL | 2 | 01-23-2008 05:57 AM |
| Column to row transformation | JobHelper | Data Warehousing | 2 | 01-18-2008 08:27 AM |
| Row to Column | cme_prak | Data Warehousing | 3 | 01-16-2008 01:56 AM |
| Middle node ptr of a linked list | Geek_Guest | C and C++ | 1 | 07-31-2007 01:52 AM |