开发者

How do I get the last three digits of a varying length column?

开发者 https://www.devze.com 2023-04-01 23:47 出处:网络
I want to write a select statement and get the last three digits of all of the rows in a column for which the length varies.

I want to write a select statement and get the last three digits of all of the rows in a column for which the length varies.

Any ideas on how I can achieve this?

Hypothetical column:

12312398098098 
127865275

I want t开发者_StackOverflowhe resulting column to have the values: Resulting column after the script:

098
275


SELECT RIGHT(CONVERT(VARCHAR(4000), [hypothetical column]), 3) FROM table;

(Added a convert in case this is a numeric column.)

0

精彩评论

暂无评论...
验证码 换一张
取 消