我有2個SQL查詢都獲得不同ID的計數。如何結合這兩個SQL語句?
select @cntCM_CMQ = count(*)
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 and ws.ID_WorkflowType = 3 -- CMQ
select @cntCM_PRWK = count(*)
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 and ws.ID_WorkflowType = 1 -- PAPERWORK
看來,我應該能夠將它們組合成一個單一的選擇(或許還有一個CASE
語句),但我似乎無法破解它。