How to extract the substring from the value of a column in Teradata?

Substring() function in Teradata

Substring function is used to extract a portion of a string from the value of a column.It returns the string based on the arguments such as starting position and length of the string.

Syntax of substring()

The first argument is the input string that can be either string or column name.

The staring position and length are both integers. Length is the optional arguments. If we are not specify the length, the substring will return string from the starting position to end of the string.

Example 1: (with starting position and length)

As we mentioned the starting position as 10 and length of the sub string as 7 in the sub string function, the string “Science” is extracted from the given input string as below.

Teradata substring example
Teradata substring example

Result:

Science

Example 2 : (Only starting position of the string)

Result:

Class

Example 3 : (Extract a substring from a column value)

example for substring function

Result:

Substring output in Teradata

Recommended Articles