Search code examples
teradatatrim

Take only right word a field column in Teradata


I want to have only the right word of a string like this in Teradata?

Tim Tom Dave

How to trim Tim and Tom and only get Dave?

substring(ABC, Index(ABC, ' ') -1) 

This is always from left side.


Solution

  • instr allows to search backwards:

    substr(ABC, instr(ABC, ' ', -1)+1)
    

    -1 = last occurance