oracle表示百分數,加減,統計

    //////////////////
    裝置類問題----本日新增:
    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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章