以下にいくつかのコードステートメントがあり、これをはるかに単純で簡単にする方法を見つけようとしています。CASEステートメントが最適だと思いますが、数日間の試行錯誤の末、その方法を理解できませんでした。すべてのヘルプおよび/または説明をいただければ幸いです。
select Count(lcs.statename) as [Name 1]
FROM hsi.itemlc as ilc
LEFT JOIN hsi.lcstate as lcs on lcs.statenum = ilc.statenum
where lcs.statename = 'Follow Up'
AND lcnum = '412'
AND status = '0'
select Count(lcs.statename) as [Name 2]
FROM hsi.itemlc as ilc
LEFT JOIN hsi.lcstate as lcs on lcs.statenum = ilc.statenum
where lcs.statename = 'Initial Review'
AND lcnum = '412'
AND status = '0'
select Count(lcs.statename) as [Name 3]
FROM hsi.itemlc as ilc
LEFT JOIN hsi.lcstate as lcs on lcs.statenum = ilc.statenum
where lcs.statename = 'Execution'
AND lcnum = '412'
AND status = '0'
select Count(lcs.statename) as [Name 4]
FROM hsi.itemlc as ilc
LEFT JOIN hsi.lcstate as lcs on lcs.statenum = ilc.statenum
where lcs.statename = 'Holdback'
AND lcnum = '412'
AND status = '0'