Teradata Position function -To get the position of substring in a string

Position function in Teradata:

Teradata provides lot of functions to manipulate the string.Position function is used to get the position of a sub string in a string.If the given sub string is not present in the string,it will return value as 0.

Syntax

SELECT POSITION(substring IN column_name) from table_name;

Example

Empoyee_idNameAddressTechnology
121RobertNew YorkHadoop
122SusanSan FranciscoAngular

Query

SELECT Employee_id,Name,POSITION(‘YorkIN Address) as POS from Employee;

Output:

Empoyee_idPOS
1214
1220

Since the sub string ‘York’ present in the address column of the first row,the position function returns the position as 4.The address column of the second row doesn’t have ‘York’ string and it returns a value as 0.

Recommended Articles