how can Oracle extract the last three characters of a string?

In Oracle, the SUBSTR function can be used to extract the last three characters of a string.

Here is the syntax:

SUBSTR(string, start_position, [length])
  1. string: the string to be extracted
  2. starting position: count begins at 1
  3. Length is an optional parameter that specifies the number of characters to be extracted. If not specified, all characters from the start position to the end of the string will be extracted. If a length is specified, only that number of characters will be extracted.

For example, to extract the last three characters of the string “Hello World,” you can use the following statement:

SELECT SUBSTR('Hello World', -3) FROM dual;

The output is:

rld

In the above example, -3 represents counting 3 characters backward from the end of the string.

bannerAds