mysql空数据的处理

1.统计分析时,统计值为null则转为0

//统计婚姻接口调用次数
select count ,(zsj/count) as pjdysj
from(
-- 实时调用量 评论返回时间差(取平均值)
select count(1) as count ,ifnull(sum(TIMESTAMPDIFF(day,a.DTJRQ,b.RKSJ)),0) as zsj
from dsr_hc_bm a ,dsr_hc_hy b
where a.dbmbh='dsr_hc_hy'
and a.DTJRQ like CONCAT('2019','%')
and b.RKSJ like CONCAT('2019','%')
and a.dhcid = b.hyhcid
)c

2.查询字段值为空的数据:空值不一定等于空字符

select * from sr_main where (mhzsfz is null  or mhzsfz = '');

posted @   武魂95级蓝银草  阅读(481)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示