我需要从选择中得到一个案例陈述:
select buyer id,
buyer_add
buyer_city,
buyer_state,
, case
when Special_Desc like "%ma%" then "Mail"
when Special_Desc like "%pa%" then "phone"
else " "
end as Special_Handling
from
( select string_func(buyer_id)
from advance.pledge p) Special_Desc
from buyer_info
where..
换句话说,我需要在Special_desc上做一个将从Select语句中生成的案例
先谢谢你。
答案 0 :(得分:0)
Hi this is an example which illustrates how to use case within a select statement. I hope this query resolves your problem. Please let me know for any issues. Thanks
SELECT sr_no,
(SELECT
CASE
WHEN UPPER(name)=UPPER('Avrajit') THEN 'My_name1'
WHEN UPPER(name)=UPPER('Shubhojit') THEN 'My_name2'
END FROM Avrajit
) AS condition
FROM avrajit;
答案 1 :(得分:0)
你应该这样:
select buyer id,
buyer_add
buyer_city,
buyer_state,
case
when regexp_like(s.Special_Desc, 'ma*', 'i') then 'Mail'
when regexp_like(s.Special_Desc, 'pa*', 'i') then 'Phone'
else ' '
end as Special_Handling
from ( select string_func(buyer_id)
from advance.pledge p) s,
buyer_info
where..
当然你需要关联这两个表。
答案 2 :(得分:0)
我通过使用case语句中的函数来解决问题。 案件 当STRING_FUNCTION(g.gift_donor_id)喜欢('%MA%') 那么'MAIL' 当STRING_FUNCTION(g.gift_donor_id)喜欢('%MA%') 然后'电话' 别的'' 结束为Special_H
感谢所有人的宝贵帮助。