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))
It could be this using the SUBSTR function in MySQL: SELECT `name` FROM `students` WHERE `marks` > 75 ORDER BY SUBSTR(`name`, -3), ID ASC; SUBSTR(name, -3) will select the last three characters in the name column of the student table.
Use the RTrim function to remove characters, usually trailing blanks, from the right of a string.
The Oracle LTRIM() function is used to remove all specified characters from the left end side of a string. Optionally you can specify an initial character or characters to trim to, or it will default to a blank.
A closing parenthesis is in the wrong place. It should be:
SUBSTR(ooo.CO_NAME, 1, LENGTH(ooo.CO_NAME) - 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With