我正在尝试将以下 IFF 表达式从 INFORMATICA 转换为 Snowflake SQL 语句(列代码是表中的列),但我无法:
iif(substr(CODE,0,6)='CE-PUU','70NPU'||substr(CODE,7),iif(substr(CODE,0,5)='AR-70','70N' ||substr(CODE,6),iif(substr(CODE,0,3)='HD-','70D'||substr(CODE,4),解码(substr(CODE,0,4),'HP -B','7PB','HP-A','70P','HP-C','7PC','HP-X','7PX','IT-T','70T','HP -D','7PD','HP-Z','7PZ',substr(CODE,0,4))||substr(CODE,5))))
我尝试使用 case 语句,但它抛出 NULL
试试这个
CASE
WHEN SUBSTR(CODE, 1, 6) = 'CE-PUU' THEN '70NPU' || SUBSTR(CODE, 7)
WHEN SUBSTR(CODE, 1, 5) = 'AR-70' THEN '70N' || SUBSTR(CODE, 6)
WHEN SUBSTR(CODE, 1, 3) = 'HD-' THEN '70D' || SUBSTR(CODE, 4)
ELSE
DECODE(SUBSTR(CODE, 1, 4),
'HP-B', '7PB',
'HP-A', '70P',
'HP-C', '7PC',
'HP-X', '7PX',
'IT-T', '70T',
'HP-D', '7PD',
'HP-Z', '7PZ',
SUBSTR(CODE, 1, 4)
) || SUBSTR(CODE, 5)
END