How to get rightmost 10 places of a string in oracle

tismon picture tismon · Oct 8, 2010 · Viewed 80.7k times · Source

I am trying to fetch an id from an oracle table. It's something like TN0001234567890345. What I want is to sort the values according to the right most 10 positions (e.g. 4567890345). I am using Oracle 11g. Is there any function to cut the rightmost 10 places in Oracle SQL ?

Thanks in advance

tismon

Answer

codaddict picture codaddict · Oct 8, 2010

You can use SUBSTR function as:

select substr('TN0001234567890345',-10) from dual;

Output:

4567890345