当前位置: 代码迷 >> SQL >> 统计表格的sql
  详细解决方案

统计表格的sql

热度:23   发布时间:2016-05-05 11:11:23.0
统计报表的sql

?

?

统计报表sql

?

select t2.checkunit_uuid,       t2.checkunit_zone,       count(t.uuid) as atotal,       sum(decode(t.get_card_status, 1, 1, 0)) as getTocal,       sum(decode(t.get_card_status, null, 1, 0))as  noGetTocal,      to_char( round(sum(decode(t.get_card_status, 1, 1, 0))/count(t.uuid)*100,10),'fm990.00')||'%' as comp  from examineedetail t, examineedate t2 where t.uuid = t2.detail_uuid   and t.credential_code is not null   and t.plan_uuid = 'cbaa6d10-68a6-4ac2-8932-dd87c00f16fd'   and t2.checkunit_uuid = '6063e9d1-c2c3-41ab-b349-574a17098e4c' group by rollup( t2.checkunit_zone,t2.checkunit_uuid) having grouping(t2.checkunit_uuid) = '0' or (grouping(t2.checkunit_uuid) = '1' and grouping(t2.checkunit_zone) = '1' )

?

?

 select        t2.checkunit_uuid as checkId,        t2.checkunit_zone as checkZone,        count(t.uuid) as atotal,        sum(decode(t.get_card_status,        1,        1,        0)) as getTocal,        sum(decode(t.get_card_status,        null,        1,        0))as  noGetTocal,        to_char( round(sum(decode(t.get_card_status,        1,        1,        0))/count(t.uuid)*100,        10),        'fm990.00')||'%' as comp      from        examineedetail t,        examineedate t2      where        t.uuid = t2.detail_uuid          and t.credential_code is not null          and t.plan_uuid='cbaa6d10-68a6-4ac2-8932-dd87c00f16fd'      group  by        rollup((t2.checkunit_uuid,        t2.checkunit_zone))

?



?兄弟帮忙给写的,学习下

?

?

?

?

  相关解决方案