【发布时间】:2022-12-07 02:22:51
【问题描述】:
在这里有这个案例陈述,我想与“CASE WHEN”和“CASE ILIKE”一起使用,类似于以下内容:
SELECT
CASE coalesce(lower(regexp_substr(random_sample_column, '\/key_word\/\\d+\/([\\w-]+)(\/|$)', 1, 1, 'e', 1)), random_sample_column)
when 'green' then 'GO'
when 'red' then 'STOP'
when 'yellow' then 'SLOW'
else
case when coalesce(lower(regexp_substr(random_sample_column, '\/key_word\/\\d+\/([\\w-]+) ilike '%green' then 'GO?'
case when coalesce(lower(regexp_substr(random_sample_column, '\/key_word\/\\d+\/([\\w-]+) ilike '%yellow' then 'SLOW?'
case when coalesce(lower(regexp_substr(random_sample_column, '\/key_word\/\\d+\/([\\w-]+) ilike '%red' then 'STOP?'
END as sample_derived_column
FROM SAMPLE_TABLE_NAME;
有没有一种方法可以编写类似于代码块顶部“CASE WHEN”语句中使用的“速记”的(NESTED)类似案例语句?
提前致谢!
样本数据在这里:
random_sample_column
--------------
yellow30-1123$%schmidt
jingle43123heimer
red
isthelightgreen
beluw
beow
blue
【问题讨论】:
-
你能发布一些样本数据吗?
-
刚刚发布了一些@Rajat,谢谢!
标签: sql snowflake-cloud-data-platform