693579551 发表于 2016-11-15 07:17:31

db2递归截取字符串

with n(str, ori, pos) as (
values ('AA,BB,CC,DD,', 1, posstr('AA,BB,CC,DD,', ','))
union all
select str, pos+1, locate(',', str, pos+1)
from n
where locate(',', str, pos+1)>0)
select str, ori, pos, substr(str, ori, pos-ori) as result from n order by pos desc fetch first 1 rows only;
//其实我只是要取一个字符串中用','分割的最后一段。。。
页: [1]
查看完整版本: db2递归截取字符串