将informatica中的iff表达式转换为雪花查询

问题描述 投票:0回答:1

我正在尝试将以下 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

snowflake-cloud-data-platform informatica
1个回答
0
投票

试试这个

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
© www.soinside.com 2019 - 2024. All rights reserved.