Skip to main content

LEFT

Returns the left-most number of characters in a string.

Syntax​

LEFT ( string_expression,  numeric_expression ) 

Arguments​

string_expression
A valid string expression.

numeric_expression
An expression that evaluates to numeric value.

Return Type​

Returns values of type STRING.

Remarks​

  • The numeric_expression must be non-negative.
  • If the number of characters exceeds the length of the string. The string is returned.

Examples​

Examples in this section use the example blockchain.

The following example returns the 2 left-most characters in the column str.

SELECT LEFT(str, 2) FROM example;

Response:

LEFT(str, 2) [STRING]
NULL
d
le
di