LEFT and RIGHT

Description

These functions return the specified number of leftmost or rightmost characters from a character string. (SQL Language References LEFT and RIGHT function).

Grammar Syntax

LEFT( string,  integer )

RIGHT( string,  integer )

This function is fully supported by Snowflake.

Sample Source Patterns

Input Code:

IN -> Redshift_01.sql
SELECT LEFT('Chicago', 3) AS left_3, RIGHT('Chicago', 3) AS right_3;

Output Code:

OUT -> Redshift_01.sql
SELECT LEFT('Chicago', 3) AS left_3, RIGHT('Chicago', 3) AS right_3;

Know Issues

In Snowflake and Redshift, the LEFT and RIGHT functions handle negative values differently:

  • Snowflake: Returns an empty string when the second argument is negative.

  • Redshift: Raises a runtime error with negative values.

There are no known issues.

Last updated