0
Mark Bannister在這個論壇上非常友好,可以幫助我創建原始查詢。我試圖修改它以包含case語句中列出的項目的條件邏輯。查詢的目標可能包含特定軟件項目的一個或另一個版本。該查詢將返回任一項作爲兼容。是否有可能在聯盟的所有部分中包含邏輯,還是有另一種方法來實現這一點?T-SQL查詢:在'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