Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

Print a certain number of characters from the end of the string SQL DB2

In DB2 I want to get 3 symbols from the end of the string. How can I do that? Example:

Input:

yyre*dsnj*001*19
asdf*wqer*136002*20

Output:

001
002

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

RIGHT function ALPHA has a value of ABCDEF.

SELECT RIGHT(ALPHA,3)
     FROM SYSIBM.SYSDUMMY1

returns DEF,

https://www.ibm.com/support/producthub/db2/docs/content/SSEPGG_11.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000844.html?pos=2


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...