RIGHT
Description
Sample Source Pattern
Syntax
RIGHT ( character_expression , integer_expression ) RIGHT( <expr> , <length_expr> )function RIGHT(string, index){
if(index< 0){
throw new RangeError('Invalid INDEX on RIGHT function');
}
return string.slice( string.length - index, string.length );
}Examples
SELECT RIGHT('John Smith', 5) AS LAST_NAME LAST_NAME|
------------+
Smith| SELECT RIGHT('John Smith', 5) AS LAST_NAME LAST_NAME|
------------+
Smith| CREATE OR REPLACE FUNCTION right_str(str varchar, index float)
RETURNS string
LANGUAGE JAVASCRIPT
AS
$$
function RIGHT(string, index){
if(index< 0){
throw new RangeError('Invalid INDEX on RIGHT function');
}
return string.slice( string.length - index, string.length );
}
return RIGHT(STR, INDEX);
$$;
SELECT RIGHT_STR('John Smith', 5) AS LAST_NAME; LAST_NAME|
------------+
Smith| Last updated
Was this helpful?