Reputation: 63
how to get sub string of an integer in DB2?
Example: 1023123 must be given as 1023
Upvotes: 1
Views: 2608
Reputation: 6240
Have a look at the VARCHAR and SUBSTR functions. You will use something like this:
SUBSTR(VARCHAR(1023123), 1, 4)
Edit: based on your comment you'll need to use these as well: CASE and LENGTH.
Upvotes: 2