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

  • 相关阅读:
    栈和队列
    链表
    map
    二叉平衡树旋转
    二叉排序树详情
    红黑树详情
    查并集
    动态规划
    位操作
    字典树
  • 原文地址:https://www.cnblogs.com/liuzhengkun/p/15161714.html
Copyright © 2011-2022 走看看