case when then用法

--简单Case函数
CASE sex
WHEN '' THEN '男'
WHEN '' THEN '女'
ELSE '其他' END //案例
select cid as 渠道编号,
case cid when '' then '华为' when '' then '小米' else cid end as 渠道名称, //别名 渠道名称,遇见3表示华为渠道,遇到20645表示小米渠道
intdate as 注册日期,
install as 激活人数,
reg2 as 注册人数,
concat(
left(reg2 / install *, ), '%') as 注册率,
ip as 去重IP数,
device as 去重设备数,
charge_user as 充值人数,
charge_times as 充值次数,
charge_money as 充值面额,
charge_money2 as 新增充值面额,
concat(
left(day1 / reg2 *, ), '%') as 次日留存率,
concat(
left(day2 / reg2 *, ), '%') as 2日留存率,
concat(
left(day3/ reg2 *, ), '%') as 3日留存率,
concat(
left(day4 / reg2 *, ), '%') as 4日留存率,
concat(
left(day5 / reg2 *, ), '%') as 5日留存率,
concat(
left(day6 / reg2 *, ), '%') as 6日留存率,
concat(
left(day7 / reg2 *, ), '%') as 7日留存率
from union_data
where intdate>= ''
and intdate<= ''
上一篇:线程和Python—Python多线程编程


下一篇:Ubuntu环境下,项目出现:Call to undefined function curl_init() 提示