raji
raji

Reputation: 63

how to get sub string of an integer value in DB2? how to use in query

how to get sub string of an integer in DB2?

Example: 1023123 must be given as 1023

Upvotes: 1

Views: 2608

Answers (1)

Benny Hill
Benny Hill

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

Related Questions