zoukankan      html  css  js  c++  java
  • 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 = '');

  • 相关阅读:
    心得
    第七章
    第六章
    第五章
    第四章
    第三章
    第二章
    第一章
    实验2(4)
    实验2(3)
  • 原文地址:https://www.cnblogs.com/tongcc/p/12222298.html
Copyright © 2011-2022 走看看