Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Matthew Elders asked how to select only the last 4 digits of an integer column and said he had found a hacky way himself. Richard Kofler recommended the modulo function, SELECT MOD(integercolumn, 10000) FROM sometable, with 10 giving the last digit and 100 the last two. Matthew called it perfect. Solved.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Hey guys,
I'm having trouble figuring out how to select only the last 4 digits of an
integer column. I'm sure that I've done it before, but I can't remember how.
Any help would be greatly appreciated.
MATTHEW ELDERS schrieb:
> Hey guys,
>
> I'm having trouble figuring out how to select only the last 4 digits of an
> integer column. I'm sure that I've done it before, but I can't remember how.
> Any help would be greatly appreciated.
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
Hi Matthew,
the modulo function is your friend.
Example:
SELECT
MOD(integercolumn, 10000)
FROM
sometable;
Where
MOD(integercolumn, 10) gives the rightmost digit
MOD(integercolumn, 100) gives the 2 rightmost digits
and so on.
HTH
dic_k
--
Richard Kofler
SOLID STATE EDV
Dienstleistungen GmbH
Vienna/Austria/Europe
That is perfect. Thank you so much. The way I found to do it was cluegy and
hackish. Have a good one.
Your privacy choices
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.