如果以下条件匹配
,我选择让我们说两个表中的user_nameuser_name=DECODE (krt.user_name,' ',' ', RTRIM (krt.user_name))
user_name=DECODE(length(krt.user_name),10,krt.user_name,16,substr(krt.user_name,6,10))
如何合并这两个陈述。?
非常感谢任何帮助。
答案 0 :(得分:1)
使用CASE
声明:
with krt as (
select ' ' user_name from dual union all
select '1234567890' from dual union all
select '1234567890123456' from dual
)
select case
when krt.user_name = ' ' then krt.user_name
when length( RTRIM (krt.user_name)) = 10 then RTRIM (krt.user_name)
when length( RTRIM (krt.user_name)) = 16 then substr( RTRIM (krt.user_name),6,10)
end
from krt