In order to return the last ‘N’ character of the column in postgresql we use RIGHT() function. RIGHT() function of column in postgresql returns the last n characters. Let’s see how to
- Return last ‘N’ character of the column in postgresql using RIGHT() function
Syntax of RIGHT():
RIGHT(string,n)
We will be using Zipcodes table.
Return Last ‘N’ character of the column in Postgresql:
In order to return last n character of the column in postgresql. We use RIGHT() function as shown below.
select *,RIGHT(city,5) as last_n FROM zipcodes
Right function of city column extracts last 5 characters so the resultant dataframe will be