Alternatives to LEFT() and RIGHT() string functions

A LEFT() function generally is used to extract n number of characters specified in the argument from the left of a given string. A RIGHT() function generally is used to extract n number of characters specified in the argument from the right of a given string.

Neither of those functions are directly supported in Firebolt. However, using the Firebolt SUBSTR and REVERSE functions, the same results can be achieved.

LEFT() Alternative

Use SUBSTR() instead of LEFT() to get characters from the left of a string. Example:

SELECT SUBSTR('Your string column here',1,11);/* returns "Your string" */

RIGHT() alternative

Use SUBSTR() with negative numbers, or SUBSTR() and REVERSE combined to get characters from the right of a string. SUBSTR() with negative numbers is the more efficient choice. Examples:

SELECT SUBSTR('Your string column here',-4,4)/* returns "here" */SELECT (REVERSE(SUBSTR(REVERSE('Your string column here'),1,4)))/* returns "here" */