zoukankan      html  css  js  c++  java
  • 多sql查询count合并为一行

    with temp1 as (
    select count(*) as riskNum from dsc.dsc_risk_event
    <include refid="Where_Clause_Assets"/>
    ),
    temp2 as (
    select count(*) as todayNew from dsc.dsc_risk_event
    <include refid="Where_Clause"/>
    ),
    temp3 as (
    select count(*) as noDeal from dsc.dsc_risk_event
    <include refid="Where_Clause_Assets"/> and status in ('0', '1')
    ),
    temp4 as (
    select count(*) as deal from dsc.dsc_risk_event
    <include refid="Where_Clause_Assets"/> and status in ('2', '-1')
    ),
    temp5 as (
    select count(*) as low from dsc.dsc_risk_event
    <include refid="Where_Clause_Assets"/> and riskLevel = '1'
    ),
    temp6 as (
    select count(*) as medium from dsc.dsc_risk_event
    <include refid="Where_Clause_Assets"/> and riskLevel = '2'
    ),
    temp7 as (
    select count(*) as high from dsc.dsc_risk_event
    <include refid="Where_Clause_Assets"/> and riskLevel = '3'
    ),
    temp8 as (
    select eventTime as warnTime from dsc.dsc_risk_event
    <include refid="Where_Clause_Assets"/> order by eventTime desc limit 1
    )
    select riskNum, todayNew, noDeal, deal, low, medium, high, warnTime
    from temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8

  • 相关阅读:
    egret inspect插件安装失败处理方法
    SQLite – GROUP BY
    JSP Connect Database
    Sticks
    TCP-IP-part7-IP协议相关技术(一)
    Tensorflow 错误集锦
    数据结构队列的实现
    使用 Git 删除本地仓库和远端仓库文件
    垃圾回收GC
    SpringDataJpa2
  • 原文地址:https://www.cnblogs.com/liuzhengkun/p/15161714.html
Copyright © 2011-2022 走看看