扫码加入数据分析学习群
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数字化人才认证。欢迎交流,共同成长!