Reputation: 415
I have a table with a column that contains a string of numbers and I only want to return the last couple of digits.
For example:
column1 | column2
_________________
Blah | 1231357
I need a select that will return the last couple of digits from the second column.
Upvotes: 0
Views: 171
Reputation: 562240
A modulus operator will take only the last two digits.
SELECT MOD(column2, 100) FROM mytable
Change 100 to 1000 to get three digits, etc.
Upvotes: 1
Reputation: 8836
Use the RIGHT
function:
SELECT RIGHT(column2, 3) AS LastDigits FROM TableName
Change 3
to the number of digits you want.
Upvotes: 2