SQL查询语句case when then问题,高手进啊,不胜感激

2025-02-25 05:02:25
推荐回答(1个)
回答1:

select userid,
case when substring(consumpattr,0,2)='10' and substring(consumpsort,0,2)= '10' then '10'
when substring(consumpattr,0,2)='10' and substring(consumpsort,0,2)<>'10' then '20'
when substring(consumpattr,0,2)='20' and substring(consumpsort,0,2)<>'70' then '20'
when substring(consumpattr,0,2)='30' and substring(consumpsort,0,2)<>'70' then '70'
else '70' end as consumpattr
from busi.t_ar_userinfo