我有一个case语句,它根据条件派生字符串字段的特定部分。
例子:
customer_id
7115878969-127881041-000000
650030087-1
130715315-1
2956599329-154074046-000000
127243855-1
请在下面找到我的当前代码:
case
when substr(reverse(trim(customer_id)),1,instr(reverse(trim(customer_id)),'-')-1)='000000'
then split_part(customer_id, '-', 2)
when substr(reverse(trim(customer_id)),1,instr(reverse(trim(customer_id)),'-')-1)<>'000000'
then trim(substr(customer_id,1,instr(customer_id,'-')-1))
--else 'error'
end as PN
,
它检查右侧的“000000”。但我需要根据“-“if two”-“then 127881041 middle part of two”-“if one”-“then 650030087更改条件
谢谢
暂无答案!
目前还没有任何答案,快来回答吧!