LTRIM FUNCTION IN TERADATA
In this article, we will learn about LTRIM FUNCTION IN TERADATA
Returns the string argument string1, with its left-most characters removed up to the first character that is not in the string argument string2.
The name of the database where the function is located.
a character string or string expression.
an optional string of characters that will be removed from string1.
If string2 is not specified, the default is to use a single space character.
This is a Teradata extension to the ANSI SQL:2011 standard.
Argument Types and Rules
Expressions passed to this function must have the following data types:
- string1 = VARCHAR or CLOB
- string2 = VARCHAR
If any of the input arguments are NULL, the function returns NULL.
You can also pass arguments with data types that can be converted to the above types using the implicit data type conversion rules that apply to UDFs.
Note: The UDF implicit type conversion rules are more restrictive than the implicit type conversion rules normally used by Teradata Database. If an argument cannot be converted to the required data type following the UDF implicit conversion rules, it must be explicitly cast.
The result data type and character set are the same as those of the string1 argument. For example, if the string1 argument has a data type of VARCHAR CHARACTER SET UNICODE, the result data type is VARCHAR CHARACTER SET UNICODE.
The following query returns the result ‘XxyLAST WORD’. LTRIM removes the individual occurrences of ‘x’ and ‘y’, and it stops removing characters when it encounters ‘X’ because ‘X’ is not in the string2 argument.
SELECT LTRIM('xyxXxyLAST WORD','xy');
The following query returns the result ‘LEFT TRIM’. LTRIM removes the spaces from the left, and it stops removing characters when it encounters ‘L’ because ‘L’ is not in the string2 argument. Since the string2 argument is not explicitly specified, the default of a single space is used.
SELECT LTRIM(' LEFT TRIM');