1

I'm trying to substring the last 3 digits from a column. Problem is, some of them have a random space at the end, which then only returns 2 of the 3 needed values from the column. Right now I have:

    SELECT substr(infovalue, -3)
    FROM TABLE
    WHERE INFOCODE = 555

How can I get my statement to ignore the space at the end?

thanks!

2
  • Does the space need to be there? Commented Aug 28, 2014 at 18:37
  • 1
    What RDBMS (Versions of trim may work here) Commented Aug 28, 2014 at 18:38

1 Answer 1

2

I guess you are in Oracle. Apply an rtrim to remove all trailing spaces

SELECT substr(rtrim(infovalue), -3)
FROM TABLE
WHERE INFOCODE = 555

And please specify the vendor & product version for all your questions.

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! This works...I will specify vendor and product from now on!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.