SQL> with test (col) as
2 (select 'SE8000901008' from dual union all
3 select 'SE8000901008_' from dual
4 )
5 select col,
6 replace(col, '_') result
7 from test;
COL RESULT
------------------------------ ------------------------------
SE8000901008 SE8000901008
SE8000901008_ SE8000901008
SQL>
with test (col) as
(select 'SE8000901008' from dual union all
select 'SE8000901008_' from dual
)
SELECT
CASE WHEN INSTR(col, '_') > 0 then
SUBSTR(col, 1, INSTR(col, '_') -1 )
ELSe col
ENd IF
FROM test
2条答案
按热度按时间zwghvu4y1#
如果您想删除下划线,那么
replace
可能比substr + instr
组合更好。xe55xuns2#
您可以检查是否有任何underscre,并选择其他选项
| 中频|
| - ------|
| SE8000901008|
| SE8000901008|
fiddle