热线电话:13121318867

登录
2021-02-24 阅读量: 726
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.

55.5627
0
关注作者
收藏
评论(0)

发表评论

暂无数据