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.

SYNTAX:

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;

left_str
--------
rainy

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

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

right_str
---------
y day

See also  How to delete unused EBS Volumes from AWS Management Console