-1

询问

select sis.subject_code||'_'||LEFT(REPLACE(sis.SIS_TERM_ID,0,''),LENGTH(sis.SIS_TERM_ID) - 4)||''|| REPLACE(SUBSTR(sis.SIS_TERM_ID, 8, 8),'','') 
from TableX;

结果如下所示 XXXX888543_134 1 ---最后一个值之前有一个空格。我不确定这是从哪里得出的。请对我可以在上面的字符串中修改的内容有任何想法。

4

1 回答 1

1

Assuming the space is really a space, how about doing the replace() across the whole string?

select replace(sis.subject_code || '_' || LEFT(REPLACE(sis.SIS_TERM_ID, 0, ''), LENGTH(sis.SIS_TERM_ID) - 4) || SUBSTR(sis.SIS_TERM_ID, 8, 8), '', '') 

It is unclear whether the replace is coming from the last element or the one before it. But you don't seem to want any spaces in the string.

于 2018-05-14T00:51:12.010 回答