case when then用法
Posted Xiao|Deng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了case when then用法相关的知识,希望对你有一定的参考价值。
--简单Case函数 CASE sex WHEN ‘1‘ THEN ‘男‘ WHEN ‘2‘ THEN ‘女‘ ELSE ‘其他‘ END
//案例 select cid as 渠道编号, case cid when ‘3‘ then ‘华为‘ when ‘20645‘ then ‘小米‘ else cid end as 渠道名称, //别名 渠道名称,遇见3表示华为渠道,遇到20645表示小米渠道 intdate as 注册日期, install as 激活人数, reg2 as 注册人数, concat( left(reg2 / install *100, 5), ‘%‘) as 注册率, ip as 去重IP数, device as 去重设备数, charge_user as 充值人数, charge_times as 充值次数, charge_money as 充值面额, charge_money2 as 新增充值面额, concat( left(day1 / reg2 *100, 5), ‘%‘) as 次日留存率, concat( left(day2 / reg2 *100, 5), ‘%‘) as 2日留存率, concat( left(day3/ reg2 *100, 5), ‘%‘) as 3日留存率, concat( left(day4 / reg2 *100, 5), ‘%‘) as 4日留存率, concat( left(day5 / reg2 *100, 5), ‘%‘) as 5日留存率, concat( left(day6 / reg2 *100, 5), ‘%‘) as 6日留存率, concat( left(day7 / reg2 *100, 5), ‘%‘) as 7日留存率 from union_data where intdate>= ‘20161020‘ and intdate<= ‘20161031‘
以上是关于case when then用法的主要内容,如果未能解决你的问题,请参考以下文章