是否可以返回冒号(:)左侧的所有字符?
当前返回:
J441:CHRONICOBSTRUCTIVEPULMONARYDISEASEW
O80:ENCOUNTERFORFULL-TERMUNCOMPLICATEDDE
I7389:OTHERSPECIFIEDPERIPHERALVASCULARDI
我想返回J441,O80和I7389。
谢谢。
答案 0 :(得分:0)
SELECT NVL(SUBSTR('J441:CHRONICOBSTRUCTIVEPULMONARYDISEASEW', 0, INSTR('J441:CHRONICOBSTRUCTIVEPULMONARYDISEASEW', ':')-1), 'J441:CHRONICOBSTRUCTIVEPULMONARYDISEASEW') AS output
FROM DUAL
返回J441
with t1 as
(
select 'J441:CHRONICOBSTRUCTIVEPULMONARYDISEASEW' as col from dual
union all
select 'O80:ENCOUNTERFORFULL-TERMUNCOMPLICATEDDE' from dual
union all
select 'I7389:OTHERSPECIFIEDPERIPHERALVASCULARDI' from dual
) SELECT NVL(SUBSTR(col, 0, INSTR(col, ':')-1), col) AS output
FROM t1