2

I want to extract everything after last comma

abc,xyz,tuv
abc,123,abc,def

I want the result as

tuv
def
leftjoin
  • 36,950
  • 8
  • 57
  • 116
user3044949
  • 81
  • 1
  • 4

2 Answers2

1

Using regexp_extract:

regexp_extract(col,',([^,]+)$',1)

Using split:

split(col,',')[size(split(col,','))-1]
leftjoin
  • 36,950
  • 8
  • 57
  • 116
0

Pls use

substr(col,-1*instr(col,',',-1)+1)

So here instr will find position of comma from end of string. Then substring will pick that many string from end.

Koushik Roy
  • 6,868
  • 2
  • 12
  • 33