All Forums General
ksaikrishna 26 posts Joined 08/11
29 Jun 2012
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

ulrich 816 posts Joined 09/09
29 Jun 2012

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....

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

Adeel Chaudhry 773 posts Joined 04/08
02 Jul 2012

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

 

HTH!

-- If you are stuck at something .... consider it an opportunity to think anew.

Amit Kumar 14 posts Joined 08/11
30 Aug 2014

Hi ksaikrishna,
Here you go....
SELECT substr(LAST_NAME, character(LAST_NAME)-2) from EMPLOYEES;
 
Cheers,
Amit

You must sign in to leave a comment.