这个论坛上的 Mark Bannister 非常友好地帮助我创建了原始查询。我正在尝试修改它以包含 case 语句中列出的项目的条件逻辑。查询的目标可能包含某些软件项目的一个或另一个版本。查询将返回任一项目为合规的。是否可以在 union all 部分中包含逻辑,或者是否有其他方法可以做到这一点?
SELECT MIN(CASE
WHEN DN.Name = 'Adobe Reader XI (11.0.01)' THEN CASE ARP.Version0 WHEN '11.0.01' THEN 'Adobe Reader Compliant' ELSE 'Adobe Reader not Compliant' END
WHEN DN.Name = 'ActivClient x86' THEN CASE ARP.Version0 WHEN '6.2' THEN 'Active Client Compliant' ELSE 'Active Client not Compliant' END
WHEN DN.Name = 'Adobe Flash Player 11 ActiveX' THEN CASE ARP.Version0 WHEN '11.7.700.202' THEN 'Adobe Flash Player Compliant' ELSE 'Adobe Flash Player not Compliant' END
WHEN DN.Name = 'Adobe Shockwave Player 12.0' THEN CASE ARP.Version0 WHEN '12.0.2.122' THEN 'Adobe Shockwave Compliant' ELSE 'Adobe Shockwave not Compliant' END END) as Complaint
From (Select 'Adobe Reader XI (11.0.01)' NAME UNION ALL SELECT 'ActivClient x86' UNION ALL SELECT 'Adobe Flash Player 11 ActiveX' UNION ALL SELECT 'Adobe Shockwave Player 12.0') as DN
CROSS JOIN dbo.v_R_System AS SYS
LEFT JOIN dbo.v_Add_Remove_Programs AS ARP
ON ARP.ResourceID = SYS.ResourceID AND ARP.DisplayName0 = DN.Name
WHERE (SYS.Netbios_Name0 = @System_Name)
GROUP BY SYS.Netbios_Name0, DN.Name
例如更改为:
WHEN DN.Name = 'ActivClient x86' or DN.Name = 'ActivClient x64' THEN CASE ARP.Version0 WHEN '6.2' THEN 'Active Client Compliant' ELSE 'Active Client not Compliant' END