oracle表示百分数,加减,统计

来源:互联网 发布:linux stat struct 编辑:程序博客网 时间:2024/04/26 22:51
    //////////////////
    装置类问题----本日新增:
    select to_char(sysdate,'yyyy-MM-hh'),count(dcid) from B82_MRZCSBZZ_TD
    where to_char(fxsj,'yyyy-MM-hh')=to_char(sysdate,'yyyy-MM-hh')
    group by to_char(sysdate,'yyyy-MM-hh');
    //////////////////
    累计发现:
    select count(dcid) from B82_MRZCSBZZ_TD where fxwt is not null;
    //////////////////
    未整改数量:
    select count(dcid) from B82_MRZCSBZZ_TD
    where zgqk is not null and zgqk not like '验收完成'
    group by dcid
    //////////////////
    已完成整改数量:    
    select sum(case when instr(zgqk, '验收完成')>0 then 1 else 0 end) cd
    from B82_MRZCSBZZ_TD
    group by dcid
    //////////
    合成:
    select sum(case when instr(zgqk, '验收完成')>0 then 1 else 0 end) yzgsl,count(dcid) ljfx,
    (count(dcid)-nvl(sum(decode(zgqk, '验收完成', 1)), 0)) wzgsl,
    sum(decode(fxwt, null, 0, 1)) ljfx,
    round(to_number(nvl(sum(decode(zgqk,'验收完成',1)),0))*100/count(*),2)||'%' zgwcl
    from B82_MRZCSBZZ_TD
    where fxwt is not null and dcid='120204'
    group by dcid