Extract Last Name only from Lastname,Firstname

时间:2017-07-10 15:27:23

标签: sql oracle

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.

1 个答案:

答案 0 :(得分:1)

One method in Oracle is regexp_substr():

select regexp_substr(name, '[^,]*')