根据结果使用if语句在查询中进行查询

qgzx9mmu  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(308)

所以我有一个奇怪的问题,关于我创建的ssrs报告。

  1. SELECT rs.Name0, rs.User_Name0, rs.AD_Site_Name0, rs.User_Domain0, rs.Full_Domain_Name0, rs.Operating_System_Name_and0, eps.Active, eps.EpInstalled, eps.EpProtected,
  2. dbo.v_GS_AntimalwareHealthStatus.Enabled, dbo.v_GS_AntimalwareHealthStatus.Version, dbo.v_GS_AntimalwareHealthStatus.AntivirusEnabled, dbo.v_GS_AntimalwareHealthStatus.AntispywareEnabled,
  3. dbo.v_GS_AntimalwareHealthStatus.EngineVersion, eps.EpToBeInstalled,
  4. (SELECT rua.ProductName0
  5. FROM dbo.v_GS_CCM_RECENTLY_USED AS rua
  6. WHERE (rs.ressourceID = rua.ressourceID)) AS Kaspersky
  7. FROM dbo.v_R_System AS rs INNER JOIN
  8. dbo.v_EndpointProtectionStatus AS eps ON rs.ResourceID = eps.ResourceID INNER JOIN
  9. dbo.v_GS_AntimalwareHealthStatus ON rs.ResourceID = dbo.v_GS_AntimalwareHealthStatus.ResourceID INNER JOIN
  10. dbo.v_GS_CCM_RECENTLY_USED_APPS AS rua ON rs.ResourceID = rua.ResourceID

为了方便起见,我正在尝试选择是否在机器上启用了endpoint,以及是否也存在kaspersky。但我想不通!我不知道如何管理它,因为此查询:

  1. (SELECT rua.ProductName0
  2. FROM dbo.v_GS_CCM_RECENTLY_USED AS rua
  3. WHERE (rs.ressourceID = rua.ressourceID)) AS Kaspersky

它返回多行(因为它们是安装在目标计算机集合上的卡巴斯基的多个版本)。但我所需要的是,如果它返回一些东西(因为这意味着卡巴斯基在机器上存在),然后返回“true”或“it's installed”之类的东西。
我已经有一段时间没有做sql查询了,所以如果你能帮我的话,请提前谢谢你。

icnyk63a

icnyk63a1#

所以我终于找到了答案,答案如下:

  1. SELECT rs.Name0,
  2. rs.User_Name0,
  3. rs.AD_Site_Name0,
  4. rs.User_Domain0,
  5. rs.Full_Domain_Name0,
  6. rs.Operating_System_Name_and0,
  7. eps.Active,
  8. eps.EpInstalled,
  9. eps.EpProtected,
  10. eps.EpToBeInstalled,
  11. Case WHEN EXISTS (SELECT rua.ProductName0 FROM v_GS_CCM_RECENTLY_USED_APPS AS rua WHERE rs.resourceID = rua.resourceID AND rua.ProductName0 LIKE '%Kaspersky%')
  12. THEN 'Yes'
  13. ELSE 'No'
  14. END AS "Is Kaspersky installed?"
  15. FROM v_R_System AS rs INNER JOIN
  16. v_EndpointProtectionStatus AS eps ON rs.ResourceID = eps.ResourceID
展开查看全部

相关问题