Seek to extract the first name last name

Hello everyone...

Bit of a rush here but again, it's a forum.

I need to get the name of the first single from a string.

Example:

Full name = Brown, Richard Ryan
Full name = Green, Marie
Full name = black, Joseph H

I need to extract everything after the comma and the space before. So, my results should be:

Name = Richard
Name = Mary
Name = Joseph


Thank you very much!

Like this

SQL> with t
  2  as
  3  (
  4  select 'Brown,Richard Ryan' full_name from dual union all
  5  select 'Green,Marie' full_name from dual union all
  6  select 'Black,Joseph H' full_name from dual
  7  )
  8  select full_name, substr(full_name, instr(full_name, ',')+1, instr(full_name || ' ', ' ') - instr(full_name, ',')-1) first_name
  9    from t
 10  /

FULL_NAME          FIRST_NAME
------------------ ------------------
Brown,Richard Ryan Richard
Green,Marie        Marie
Black,Joseph H     Joseph

SQL>

Tags: Database

Similar Questions

  • Extract the first name and last names of a string

    Hello people,
    I am trying to extract the last name, first name, first name and initial of some names of students for a report. I have some success with the first name and the first names, but have some difficulty to come with the other two. I use Oracle 9i and would like to come with the SQL.

    Script to create the table:
    create table grad_student_tb
    (student_id varchar2(3) primary key,
     salutation varchar2(4),
     student_name   varchar2(60));
    Script to insert records into the table:
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('001','Mr','Adams,Robert Murphy');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('002','Mr','Green,Eric Craig');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('003','Miss','Brown,Jennifer William H');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('004','Mr','Adams,Michael William H');
    Insert into GRAD_STUDENT_TB (STUDENT_ID,SALUTATION,STUDENT_NAME) values ('005','Miss','White,Snow');
    Here's what I would like on my report:
    Student ID   First Middle Name    Last Name   First Name   Initial
    ==================================================================
    001          Robert Murphy        Adams       Robert       M
    002          Eric Craig           Green       Eric         C
    003          Jennifer William H   Brown       Jennifer     W
    004          Michael William H    Adams       Michael      W
    005          Snow                 White       Snow
    Currently my SQL looks like this:
    select student_id,
           SUBSTR(student_name, INSTR(student_name,',')+1, LENGTH(student_name)) first_middle_name,
           SUBSTR(student_name,1, INSTR(student_name,',')-1) last_name
    from   grad_student_tb;
    Output:
    STUDENT_ID FIRST_MIDDLE_NAME                                            LAST_NAME                                                    
    ---------- ------------------------------------------------------------ ------------------------------------------------------------ 
    001        Robert Murphy                                                Adams                                                        
    002        Eric Craig                                                   Green                                                        
    003        Jennifer William H                                           Brown                                                        
    I need to come up with the first name and initial of the students.

    Any help is greatly appreciated!

    Thank you

    Published by: Roxyrollers on August 18, 2011 12:53

    Assuming that each name is exactly the same format

    SQL> ed
    Wrote file afiedt.buf
    
      1  select student_id,
      2         SUBSTR(student_name,
      3                INSTR(student_name,',')+1,
      4                LENGTH(student_name)-INSTR(student_name,' ')) first_name,
      5         SUBSTR(student_name,
      6                INSTR(student_name,' ')+1) middle_name,
      7         SUBSTR(student_name,
      8                INSTR(student_name,' ')+1,
      9                1) middle_initial,
     10         SUBSTR(student_name,1, INSTR(student_name,',')-1) last_name
     11* from   grad_student_tb
    SQL> /
    
    STU FIRST_NAME      MIDDLE_NAME          MIDDL LAST_NAME
    --- --------------- -------------------- ----- ---------------
    001 Robert          Murphy               M     Adams
    002 Eric            Craig                C     Green
    003 Jennifer        William H            W     Brown
    

    In general, of course, analysis names as it is much more complicated because you have to deal with the family as "la Hoya" names that contain spaces and cannot easily be distinguished from someone with several names.

    Justin

  • SEPARATE THE FIRST NAME AND LAST NAME

    How to separate the first and last name? the first name is always first.

    With the help of 10g,.
    select (Tim Tebow) from dual

    Not an easy task.

    Sir Nicholas Mimsy Porpington
    John Jacob Jingleheimer Schmidt
    Dear

  • Need space between the first name and family name

    Hi, I use Concat to join the first and last name, but I need a space between the two...

    Hello

    Try this concat (concat ('users'. "First name",""), 'Users' '. "" Family name")

    Kind regards
    Young

  • Drop-down list box to choose a name and have just the first name see

    I have created a form for health care.

    I have a drop down box with names of doctors... their full names so that they are easily recognizable. And the following fields, then who will fill based on choice. However what I need is that, after the first and last name in the drop-down list is selected that only the name of the Dominican Republic first arises in the area which will be distributed through the file. Information is already using this Java:

    {Switch (this.) RawValue)}

    case "MD":

    Form1. Page1.Physician1LastName.RawValue = "Robert";

    Form1. Page1.Physician1Number.RawValue = "1111111111";

    Form1. Page1.Physician1Fax.RawValue = "2222222222;

    form1. Page1.ClientEmail.RawValue = "[email protected]"; ""

    Form1. Page1.Physician1Address.RawValue = "xyz suite."

    Form1. Page1.Physician1City.RawValue = "XYY Iquelqu";

    Form1. Page1.Physician1State.RawValue = "XZ";

    Form1. Page1.Physician1Zip.RawValue = "11111";

    Form1. Page1.Physician1NPI.RawValue = "111111111";

    Form1. Page1.Physician1License.RawValue = "ABBB111111";

    Form1. Page1.Physician1UPIN.RawValue = "A11111";

    Form1. Page1.Physician1Specialization.RawValue = 'internist ';

    break;

    }

    And works beautifully thanks to previous help everyone.

    Here is the example of the choices in drop-down list:

    Dr. Aaaaa Abb Accccc

    Dr. ranya Bbb Bccccc

    I like to choose:

    Dr. Aaaaa Aaaaa has

    and you select it it show only the first name in this area, so it can be properly treated by the rest of the fields.

    IE: Aaaaa (nothing else)

    I'm a horrible things like I just surf around until I find something that works and copy and paste and play until it works

    So please be specific:

    Java vs form: customer: choice and code...

    Thank you very much...

    Take a look at the attachment. The script assumes that the name is a string of three parts as Dr. Frank Burns. You can change it according to your needs.

    Form1.Page1.DD::exit - (JavaScript, client)

    If (this.rawValue! = null) {}

    var doc = this.rawValue;

    var i = doc.indexOf("");

    doc = doc.substring (i + 1, doc.length);

    this.rawValue = doc.substring (0, doc.indexOf(""));

    }

    Steve

  • Extract the host name vCenter using PowerCLI

    Hi all

    I was asked to create a script that displays the host ESX, the version of the product name (I use "Get-View $_USER.USER"). «» ""Config.Product.FullName"), and what I thought, that's easy, vCenter host name." I'm having a hard time trying to figure out how to extract the host name real vCenter. I can get the vDC and the cluster, but I can't find what combination of cmdlets or vim commands can extract this nugget. Is something that is accessible via a standard cmdlet such as get-viproperty, get-view or another?

    TIA,

    g

    Does what you're looking for?

    Get-VMHost | Select Name,@{N="vCenter";E={$_.Uid.Split(':')[0].Split('@')[1]}}
    
  • Need to extract the global name

    Hello

    I'm working on 11 GR 2 on RHEL.

    I am trying to extract the global name under the name of the comic.

    For example: If the db name is sample and if global name is sample.london.uk.com so I only need london.uk.com

    I tried to use something like REGEXP_substr (global_name, '[..] ([A-Z] * [0-9] * []] *---*'), but it does not work.

    SQL> select global_name, REGEXP_substr(global_name, '[.][A-Z]*[0-9]*[-]*[.]*' ) gname from global_name;
    
    GLOBAL_NAME                    GNAME
    ------------------------------ ------------------------------
    SAMPLE.LONDON.UK.COM           .LONDON.
    I want to extract LONDON.UK.COM

    Any suggestions?

    I want to extract LONDON.UK.COM

    SQL> with global_name as (
      select 'SAMPLE.LONDON.UK.COM' global_name from dual
    )
    --
    --
    select global_name, regexp_substr (global_name, '\.(.*)',1,1,null,1) gname from global_name
    /
    GLOBAL_NAME                    GNAME
    ------------------------------ ------------------------------
    SAMPLE.LONDON.UK.COM           LONDON.UK.COM
    1 row selected.
    
  • Fill with initial of the first name field?

    https://DL.dropbox.com/u/78503370/AFBS_IntakeAssesment_052912_STESTV3.PDF

    Hello! I'm only a graphics person, and I am just with simple scripts. I'm trying to shoot only the first initial of the PatientName_First field and have it fill in the PatientName_Initial field in the master page so that the initials of the patient will be displayed on each page of the form.

    Please do not die of laughing at my attempt to Frankenstein a script from another form in this one, I really know anything yet, but I'm learning. I was not yet able to make JavaScript work - had more success with FormCalc.

    I don't know if that's a problem, but the form must remain static. iPad can not yet read dynamic forms, and I must be compatible iPad.

    Thanks much for any help!

    Here you go:

    1. remove all the code in the event of 'change' for the PatientName_First field.  This event fires on each typed character, and in this case, you don't need to trap all the characters.

    2. Add the following code to the event "exit" to PatientName_First:

    If (this.rawValue! == null)

    this.rawValue = this.rawValue.replace(/^\s+|\s+$/g,""); "

    The foregoing will be trim spaces attack/flight of the first name field, which was what you expected and are a good idea.  Place in means of output event happen only once the user has finished typing the name and tabs out of the field.

    3. change the name of the subform that retains information name of 'PatientDemographics '.  Naming of the subforms in the hierarchy is recommended because it makes their SEO in the script easier.  See the screenshot below.

    4. Add the following code to the event of 'calculate' to the PatientName_Initial field in the master page:

    initial var = form1. PatientDemographics.PatientName_First.rawValue;

    If (initial! == null) {}

    If (initial.length > 0) {}

    this.rawValue = initial.substr (0, 1);

    }

    }

    When the name is in the main form, the calculate event fires and the script will be executed. The script will be the first name that was entered and set the initial field to the first character in the name.  Check the name = null is important because the calculate event fires when the form is opened first, before whatever it is entered.  We check to make sure there is at least one character in the first name field before trying out the first character.

    There is no need to use a dynamic form to do this, so it should work on an iPad.  Unfortunately, I can't test that.

    See you soon,.

    Kevin

  • Extract the first and the last Date of the previous month

    This seems to be a delicate but again it is perhaps easy for some of you people.

    Here is how I find the previous month

    Any ideas on how to get the first and last date of the previous month?

    Thanks in advance.

    Hello!

    SQL>
    SQL> select last_day(add_months(sysdate,-1)) from dual;
    
    LAST_DAY
    --------
    28.02.10
    
    SQL> select trunc(add_months(sysdate,-1),'MM') from dual
    
    TRUNC(AD
    --------
    01.02.10
    
    SQL> 
    

    T

  • How to: Extract the first three characters of a text field

    Greetings-

    What is the best method to extract the first three letters of a text field?

    I need to extract the first three letters of a text field (surname in this case),
    so I add other components to create an identification number for
    a person.

    This identification number which must be created consists of the
    date of the person by birth, last 4 digits of social security number and
    the first three letters of the person's first name.

    Example:
    == > Date of birth: 15/11/45
    == > Last 4 SSN: 6654
    == > Name: Smith

    Identification number would be:
    == > 1115456654SMI

    Leonard B


    That should do the trick:

    I put your values in the variable, simply replace the names, according to the needs


    This removes all the string of the / your birthday (if it's a string!) and puts it in the variable id:

    It takes the 4 last letters/digits of your social security number string and adds it to the id:

    It takes the first thre letters/numbers from your last name variable, capitalizes and adds to the identification string

    It will be useful.

  • Can only see the first and last frame of the item in the editing HELP PLEASE

    Hi, my first time and I find an answer, but fails. I first elements 4 and I'm trying to worm. 9. in version 4 clips in the timelin shows all the frames, but in ver 9 it only shows the first and last frame clips. Is it possible to make all the images to display. I mean by "all frames", clips from filling with frames. I wanted to see all of the images in the scenario, it is easier for me to select and cut the pieces on.

    My features are Core 2 Duo 6750, Nvidia 8600GTS, 4 G of Ram and Vista Home Premium. 3 HARD DRIVE 3 TB.

    Thank you for having responded

    Werner

    Werner,

    Welcome to the forum.

    In the header of the video track, there is an icon for Clip thumbnail display. It's a cycle, and you can scroll through the Modes to display the first frame, first & last, all, or none (name of file only). In pre 4.0, it's on the far left in the header of the track. I guess that's about the same place in pre 9.0.

    Good luck and hope that helps.

    Hunt

  • Impossible to print the first and last pages of a pdf of the 8 page?

    I have a pdf of 8 pages exported from an InDesign document. I can print it without any problem on my MAC, but when I will forward it to a partner, she is unable to print the first and last pages. Any ideas?

    Hi jimr67163466,

    Could you please let us know the version of Adobe Reader is installed on the machine?

    What operating system is installed on the machine-Windows/Mac?

    The pdf is printing via a network printer?

    This phenomenon happens with a specific document only or with other documents as well?

    Try to print the pdf as image, launch Adobe Reader, click Print > select your printer from the drop-down > click on advanced > check the print as Image > and then click OK.

    Let us know if it worked.

    Thank you

    Shivam

  • Changed the display pad and how can I change this back to the first and last frame of the clip in question?

    Hi, when you cut a clip using the standard cursor (not the adjustment tool but just the mouse), the behavior that I was accustomed to is it shows the first and last frame of the clip you're carved, in a 2 - up window. Now in the updated 2015 I'm confused because it's still place 2 window, but instead I see the head or tail of any clip is next to any side of the clip, I'm trying to cut. I can see the utility in this, but I would like to know where I can go to the screen more as I'm used to it...

    Thank you!

    Click on the key in the timeline and in the drop-down the menu uncheck Composite overview over the filling.

    MtD

  • Extract the first letter of each word

    Hi all

    I have a requirement to extract the first letter of each word as shown in the example below
    input: abcd output: a
    input: abcd efgh output: ae
    input: abcd efgh ijkl output: aej
    any help will be much appreciated

    I'm on the 11g version of the db

    Depends on your definition of a "word", but for example:

    SQL> select trim(regexp_replace(' a abcd efgh ijkl','(\S)\S*\s*','\1'))
      2  from dual
      3  ;
    
    TRIM(REGEXP_REPLACE('AABCDEFGH
    ------------------------------
    aaei
     
    
  • How to extract the first day of the year quarter

    Hello

    How can I write a query to extract the first day in a neighborhood of declaration

    for example: -.

    Q1 starts from April 1 to June 30, second quarter starts from July 1 to September 30, third quarter starts from 1 October to 31 December and the fourth quarter begins from January 1 to March 31.

    How can I recover then the first day of these quarters, regardless of the year. The year can be any year.

    Hello

    don't know exactly what you want, but if you want the first day of a quarter for any given date and then

    select trunc(sysdate,'Q') from dual;
    

    Sysdate obviously could be a valid date.

    André

Maybe you are looking for