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

  • 相关阅读:
    常用git命令
    复制文件
    实现斗地主洗牌、发牌、看牌
    线程池实现多线程
    git无法提交问题
    Js中处理日期加减天数
    form详解
    node.js中exports与module.exports的区别
    css的direction属性
    webstorm基础使用
  • 原文地址:https://www.cnblogs.com/liuzhengkun/p/15161714.html
Copyright © 2011-2022 走看看