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
An alternative that is similar to the other posts.
Bob Duells post is probably the most readable.
SELECT
[cntCM_PRWK] = COUNT(CASE WHEN ws.ID_WorkflowType = 1 THEN ws.ID_WorkflowState ELSE NULL END),
[cntCM_CMQ] = COUNT(CASE WHEN ws.ID_WorkflowType = 3 THEN ws.ID_WorkflowState ELSE NULL END)
FROM
dbo.CaseWorkflow cw
INNER JOIN vew_CasePersonnelSystemIDs vcps
ON cw.ID_Case = vcps.ID_Case
INNER JOIN dbo.WorkflowStates ws
ON ws.ID_WorkflowState = cw.ID_WorkflowState
WHERE CMSUID = @nSUID