How to combine these two SQL statements?

前端 未结 5 1263
说谎
说谎 2020-12-20 04:03

I have 2 SQL queries both of which get the counts for different IDs.

select @cntCM_CMQ = count(*)
from dbo.CaseWorkflow cw 
join vew_CasePersonnelSystemIDs         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 04:38

    select 
    SUM(Cast(Case when ws.ID_WorkflowType = 3 then 1 else 0 end as int) as CMQ
    ,SUM(Cast(Case when ws.ID_WorkflowType = 1 then 1 else 0 end as int) as Paperwork
    
    from dbo.CaseWorkflow cw 
    join vew_CasePersonnelSystemIDs vcps on cw.ID_Case = vcps.ID_Case
    join dbo.WorkflowStates ws on ws.ID_WorkflowState = cw.ID_WorkflowState
    where CMSUID = @nSUID 
    

提交回复
热议问题