我有这个查询: -
select col_str,
getVal,another_str,resultVal_str from tablename
得到这样的结果:
col_str getVal another_str
'11,12,33,54,1,44' '12' '9,5,4,8,7'
'11,12,33,54,1,44,10,12,11,12,12' '44' '9,5,4,8,7,6,3,5,2,4,2'
'11,12,33,54,1,44' '999' '9,5,4,8,7,4'
'11,12,33' '0' '9,5,4'
----- ---- -----
----- ---- -----
----- ---- -----
列col_str,getVal,another_str
来自表,列resultVal_str
要根据剩余的三列计算,逻辑为resultVal_str
-
查看第一条记录getVal
的值为 12 并col_str
在位置编号 2 处具有 12,然后查看位置编号 2another_str
为 5,因此resultVal_str
为 5,依此类推。见下文:
col_str getVal another_str resultVal_str
'11,12,33,54,1,44' '12' '9,5,4,8,7' 5
'11,12,33,54,1,44,10,12,11,12,12' '44' '9,5,4,8,7,6,3,5,2,4,2' 6
'11,12,33,54,1,44' '999' '9,5,4,8,7,4' 0
'11,12,33' '0' '9,5,4' 0
----- ---- ----- ---
----- ---- ----- ---
----- ---- ----- ---
我如何添加下一列resultVal_str
并获得类似上面的结果?