LEFT and RIGHT functions in Redshift database

LEFT function and RIGHT function are string functions that are used to extract the left most or right most substring of specified character length from within a string.


SELECT LEFT(string, integer);

Example: Below select query returns output as ‘rainy’ – the first 5 characters from the left.

SELECT LEFT('rainy day' , 5) as left_str;


Below select query returns the output as ‘y day’ – the last 5 characters from the right.

SELECT RIGHT('rainy day' , 5) as right_str;

y day

See also  How to perform multi-part upload to S3 using CLI