`
sun201200204
  • 浏览: 295601 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

行变列

    博客分类:
  • SQL
阅读更多
select t.bib_type,
    count(CASE when code.code='BBS001' then t.bib_type end) as Load,
    count(decode(code.code,'BBS001',t.bib_type,'')) as Load,
    count(CASE when code.code='BBS002' then t.bib_type end) as Bi,
    count(CASE when code.code='BBS003' then t.bib_type end) as Unload,
    count(CASE when code.code='BBS004' then t.bib_type end) as Wait,
    count(CASE when code.code='BBS005' then t.bib_type end) as Hold,
    count(CASE when code.code='BBS006' then t.bib_type end) as PM,
    count(CASE when code.code='BBS007' then t.bib_type end) as Clean,
    count(CASE when code.code='BBS008' then t.bib_type end) as Other,
    --count(CASE when code.code='BBS009' then t.bib_type end) as Disabled,
    count(decode(code.code,'BBS009',t.bib_type,'')) as Disabled,
    count(0) total_count,
    round(avg(t.mask_rate),2) mask_rate 
from mcs_bib t,mcs_code_m code 
where t.status=code.code and code.type='BBS' and t.status_code='0' 
group by t.bib_type;

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics