Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

PostgreSQL RIGHT() function

RIGHT() function

The PostgreSQL right() function is used to extract n number of characters specified in the argument from the right of a given string. When the value of n is negative, the extraction will happen from the right except for first n characters.

Syntax:

right(<string>,n)

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL RIGHT() function

Pictorial presentation of postgresql right function

Example 1: PostgreSQL RIGHT() function:

In the example below, the rightmost five characters from the string 'w3resource' have been extracted.

Code:

SELECT right('w3resource',5);

Sample Output:

 right
-------
 ource
(1 row)

Example 2:

In the example below, the right function extracted all the characters from the right side except 3 leftmost characters from the string 'w3resource', because the value of extracting character number is negative.

Code:

SELECT right('w3resource',-3);

Sample Output:

  right
---------
 esource
(1 row)

Previous: TRANSLATE function
Next: REVERSE function