case when then用法

來源:互聯網
上載者:User

標籤:dev   and   concat   別名   strong   裝置   日期   cas   span   

--簡單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用法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.