我的查询结果:
SELECT SYS_Product,
CASE
WHEN MEMVendor_Name = 'Unavailable' OR MEMVendor_Name = 'unknown'
THEN 'Error'
ELSE MEMVendor_Name
END AS MEMVendor_Name,
COUNT(MEMVendor_Name) AS MEMVendor_NameCount
FROM dbo.ahs_master_bc_system_mem_vendor AS V
WHERE (AHS_CurrentCfg = 1)
and SYS_Product='Gen8'
GROUP BY SYS_Product, MEMVendor_Name
如下:
SYS_Product | MEMVendor_Name| MEMVendor_NameCount
_____________________________________________
Gen8 Elpida 1
Gen8 Micron 84
Gen8 Nanya 28
Gen8 Netlist 0
Gen8 Samsung 55
Gen8 SK-Hynix 86
Gen8 Error 0 <----
Gen8 Error 2 <----
问题:我怎样才能得到 JUST the Error 的“总和”为 2(0+2) 仍然保持其他人的计数:
SYS_Product | MEMVendor_Name| MEMVendor_NameCount
_____________________________________________
Gen8 Elpida 1
Gen8 Micron 84
Gen8 Nanya 28
Gen8 Netlist 0
Gen8 Samsung 55
Gen8 SK-Hynix 86
Gen8 Error 2 <===
我需要 group by,因为这些结果将与基于 SYS_Product 和 MEMVendor_Name 的另一个查询相结合
谢谢。