zoukankan      html  css  js  c++  java
  • 对产品不同指标维度分组求和

    SELECT
    p.name,
    SUM( CASE WHEN b.type = 'codeerror' and b.status = 'active' THEN 1 ELSE 0 END ) AS funs_active,
    SUM( CASE WHEN b.type = 'codeerror' and b.status = 'active' and b.severity = 1 THEN 1 ELSE 0 END ) AS funs_active_p1,
    SUM( CASE WHEN b.type = 'codeerror' and b.status = 'active' and b.severity = 2 THEN 1 ELSE 0 END ) AS funs_active_p2,
    SUM( CASE WHEN b.type = 'codeerror' and b.status ='resolved' THEN 1 ELSE 0 END ) AS funs_resolved,
    SUM( CASE WHEN b.type = 'designdefect' and b.status = 'active' THEN 1 ELSE 0 END ) AS des_active,
    SUM( CASE WHEN b.type = 'designdefect' and b.status = 'active' and b.severity = 1 THEN 1 ELSE 0 END ) AS des_active_p1,
    SUM( CASE WHEN b.type = 'designdefect' and b.status = 'active' and b.severity = 2 THEN 1 ELSE 0 END ) AS des_active_p2,
    SUM( CASE WHEN b.type = 'designdefect' and b.status = 'resolved' THEN 1 ELSE 0 END ) AS des_resolved,
    SUM( CASE WHEN b.type = 'security' and b.status = 'active' THEN 1 ELSE 0 END ) AS sec_active,
    SUM( CASE WHEN b.type = 'security' and b.status = 'active' and b.severity = 1 THEN 1 ELSE 0 END ) AS sec_active_p1,
    SUM( CASE WHEN b.type = 'security' and b.status = 'active' and b.severity = 2 THEN 1 ELSE 0 END ) AS sec_active_p2,
    SUM( CASE WHEN b.type = 'security' and b.status='resolved' THEN 1 ELSE 0 END ) AS sec_resolved,
    sum(case when to_days(b.openedDate) = to_days(now()) THEN 1 ELSE 0 END ) AS create_num,
    sum(case when to_days(b.resolvedDate) = to_days(now()) THEN 1 ELSE 0 END ) AS resolved_num,
    sum(case when to_days(b.closedDate) = to_days(now()) THEN 1 ELSE 0 END ) AS closed_num
    FROM zt_bug b,zt_product p where b.product=p.id and p.status='normal' and b.deleted='0' and p.deleted='0' GROUP BY p.name order by p.id desc

  • 相关阅读:
    angular打包出现JavaScript堆内存不足
    antDesign 【NG-ZORRO、Angular】日期选择框时间段nz-range-picker设置默认选择日期及限制日期可选范围
    Echarts 折线图Demo调色12种,可以直接使用~~~
    公司版git完整版
    Linux实例重启服务器后root用户远程连接失败
    Flask+Redis+mq实现高并发
    Dockerfile
    Docker应用部署
    RabbitMQ 实现实现基本通信及订单处理
    centos 7 安装docker的文档参考
  • 原文地址:https://www.cnblogs.com/ruijie/p/15009826.html
Copyright © 2011-2022 走看看