Remove last character from string in sql plus

Ali Anwar picture Ali Anwar · Oct 20, 2014 · Viewed 65.4k times · Source

I'm trying to remove the last character from a column output in sql plus. The length of the column entries is not fixed

For e.g XYZA should output as XYZ

I've tried using the substr() function but it doesn't seem to work.

SUBSTR(ooo.CO_NAME,1,LENGTH(ooo.CO_NAME-1))

Answer

Troy Gizzi picture Troy Gizzi · Oct 20, 2014

A closing parenthesis is in the wrong place. It should be:

SUBSTR(ooo.CO_NAME, 1, LENGTH(ooo.CO_NAME) - 1)