How to get rightmost 10 places of a string in oracle

后端 未结 4 998
旧时难觅i
旧时难觅i 2021-01-03 18:24

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 posit

4条回答
  •  甜味超标
    2021-01-03 19:02

    Another way of doing it though more tedious. Use the REVERSE and SUBSTR functions as indicated below:

    SELECT REVERSE(SUBSTR(REVERSE('TN0001234567890345'), 1, 10)) FROM DUAL;
    

    The first REVERSE function will return the string 5430987654321000NT.

    The SUBSTR function will read our new string 5430987654321000NT from the first character to the tenth character which will return 5430987654.

    The last REVERSE function will return our original string minus the first 8 characters i.e. 4567890345

提交回复
热议问题