多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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM