美文网首页
case when ... end + count 的用法

case when ... end + count 的用法

作者: whenitsallover | 来源:发表于2018-09-11 14:52 被阅读0次
select 
count(case when from_unixtime(time/1000,'%Y-%m-%d') between '2018-01-01' and '2018-02-01' then 1 end) 一月份,
count(case when from_unixtime(time/1000,'%Y-%m-%d') between '2018-02-01' and '2018-03-01' then 1 end) 二月份,
count(case when from_unixtime(time/1000,'%Y-%m-%d') between '2018-03-01' and '2018-04-01' then 1 end) 三月份,
count(case when from_unixtime(time/1000,'%Y-%m-%d') between '2018-04-01' and '2018-05-01' then 1 end) 四月份,
count(case when from_unixtime(time/1000,'%Y-%m-%d') between '2018-05-01' and '2018-06-01' then 1 end) 五月份,
count(case when from_unixtime(time/1000,'%Y-%m-%d') between '2018-06-01' and '2018-07-01' then 1 end) 六月份,
count(case when from_unixtime(time/1000,'%Y-%m-%d') between '2018-07-01' and '2018-08-01' then 1 end) 七月份,
count(case when from_unixtime(time/1000,'%Y-%m-%d') between '2018-08-01' and '2018-09-01' then 1 end) 八月份
from table_name;

相关文章

网友评论

      本文标题:case when ... end + count 的用法

      本文链接:https://www.haomeiwen.com/subject/yvdugftx.html