我在下面有几个代码语句,我正在尝试找出一种方法来使这变得更加简单和容易。我认为 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'