心盛待花开

2021-02-24   阅读量: 542

sum case when和count case when有什么区别

扫码加入数据分析学习群

image.png


sum(case when t.ride_num=1 then 1 else 0 end ) as ride_1_times

count(case when t.ride_num=1 then 1 else null end ) as ride_1_times

count(case when t.ride_num=1 then 1 end ) as ride_1_times then=1,

两者的查询结果相同,但sum 中case when de else 需要为0,而count case when 的else需要设定为null或者不写。count默认不统计null ,不能为0.

添加CDA认证专家【维克多阿涛】,微信号:【cdashijiazhuang】,提供数据分析指导及CDA考试秘籍。已助千人通过CDA数字化人才认证。欢迎交流,共同成长!
55.5627 2 0 关注作者 收藏

评论(0)


暂无数据

推荐课程