如何在案例陈述中抛出异常?我相信signal
是正确的陈述。案例陈述是在“' corp'在名称中找到,然后在列中有1,但如果单词' dollar'在名称
Name Is_comp
Dollar Tree Corp
First Hand Corp 1
Select
when name like 'corp'
then 1
end as is_comp
答案 0 :(得分:0)
我认为,根据您所寻找的内容,您只需要一个更高级的CASE声明:
SELECT
CASE
WHEN
name LIKE ANY ('%corp%','%llc%','%inc%') /*list of names with wildcards*/
AND name not like '%Finch%' /*don't match on finch%/
AND name not like ANY ('%Finch%','%Brian%') /*or optionally don't match on any of these name substrings*/
THEN 1
END 'is_comp'
FROM <table>