I need to display only last two characters

35 pts.
Tags:
SQL
SQL Query
i need to disply only last two characters in a column, the column data like this 1.3.2NE,1.2.2NN,1.10CE,1.11.1NN,10.3 for this i need output like this NE,NN,CE,NN

Answer Wiki

Thanks. We'll let you know when a new response is added.

In oracle the command would be

select substr([your column name],-2,2) from [your table name]

In MSSQL you would use substring instead of substr.

you could also use the Right function (select right(colname,2) from table if the database engine supports it.

*******Actually no, the Right function would not work in all cases – only if the column is varchar vs.
char or nchar********

I went back and tested with the substring function in MSSQL but it did not work. But the Right
function did work for varchar column. There is no Right function in oracle.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following