--question
问题是这样的,我得到一个字符串,3c,有两个栏位里有如下信息3a,3b,3c,11,12,13,4a,4b,4c,另一个栏位里是1,2,3,4,5,6,7,8,9
也就是说通过字符串3c找到栏位一里3c对应的,号在第几个位置上,然后在第二个栏位里取该位置,号前的字符串,我想了一下用instr取到的位置不准,不知道应该怎么弄,大侠指点一下!!
--solute:
如是两位数的话,是有规律的!
可以用以下的操作:
select distinct a,trunc((b/3)+1) b from
(
select substr(a,mod(rownum,3)*rownum,2) a,
mod(rownum,3)*rownum b from
(
select '3a,3b,3c,11,12,13,4a,4b,4c' a from dual
)
connect by rownum <length(a)
) where b <>0 and a is not null
--and a='3c'
order by b
--result:
3a 1
3b 2
3c 3
11 4
12 5
13 6
4a 7
4b 8
4c 9
--other method: