-2

I just started working with Oracle recently so please bear with me.

I have a column of names as LASTNAME,FIRSTNAME and I need to extract JUST the last name. I know how to do this in excel, where I want to so search for the "," find the length of characters before the comma and return those characters.

I know to use SUBSTR as my LEFT() function, but I'm stuck from there.

Ron L
  • 51
  • 3
  • 11

1 Answers1

1

One method in Oracle is regexp_substr():

select regexp_substr(name, '[^,]*')
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786