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_id | Name | Address | Technology |
121 | Robert | New York | Hadoop |
122 | Susan | San Francisco | Angular |
Query
SELECT Employee_id,Name,POSITION(‘York‘ IN Address) as POS from Employee;
Output:
Empoyee_id | POS |
121 | 4 |
122 | 0 |
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
- Substring function in Teradata with examples
- Extract function in Teradata with examples
- STRTOK function in Teradata with examples
- Regexp_substr function in Teradata with examples