How to display the last 3 characters of lastname?

General
Enthusiast

How to display the last 3 characters of lastname?

Hi,

In oracle we used below query to display the last three characters of last_name.

SELECT SUBSTR(LAST_NAME,-3) FROM

EMPLOYEES;

Can someone help me how to perform in tetadata with outadding POSITION/INDEX?

Thanks,

Saikrishna.k

3 REPLIES
Senior Supporter

Re: How to display the last 3 characters of lastname?

substr(last_name, characters(last_name)-2,3)

You might need to add a case expression in case the last names is shorter then 3 characters....

Teradata Employee

Re: How to display the last 3 characters of lastname?

In case CHARACTERS doesn't work, you can also use CHARACTER_LENGTH function to get the length of character field.

HTH!

Enthusiast

Re: How to display the last 3 characters of lastname?

Hi ksaikrishna,

Here you go....

SELECT substr(LAST_NAME, character(LAST_NAME)-2) from EMPLOYEES;

Cheers,

Amit