DC生成禁用软件报表的查询语句

DC生成禁用软件报表的查询语句


语句可直接查询禁用软件内容包括:
软件名称,软件版本,软件厂商,许可类型,计算机名称,安装账户,域名称,远程办公室名称

select
  SOFTWARE_NAME,
  SOFTWARE_VERSION,
  MANUFACTURER_NAME,
  (
    case when sw_type = 0 then 'Unidentified' when sw_type = 1 then 'Commercial' when sw_type = 2 then 'Non Commercial' end
  ) LICENSE_TYPE,
  resource.name COMPUTER_NAME,
  INSTALLED_USER_ACCOUNT,
  resource.domain_netbios_name as Domain_Name,
  branchofficedetails.BRANCH_OFFICE_NAME as Remote_Office_Name
from
  invsw
  Inner join invswinstalled on invsw.software_id = invswinstalled.software_id
  left join invmanufacturer on invsw.manufacturer_id = invmanufacturer.manufacturer_id
  left join invswinstalledtouserrel on invswinstalled.component_id = invswinstalledtouserrel.sw_installed_id
  left join (
    select
      invswinstalled.component_id comp_id,
      (
        case when invsystemusers.name is null then 'SYSTEM' else name end
      ) INSTALLED_USER_ACCOUNT
    from
      invswinstalled
      left join invswinstalledtouserrel on invswinstalled.component_id = invswinstalledtouserrel.sw_installed_id
      left join invsystemusers on invswinstalledtouserrel.user_component_id = invsystemusers.component_id
  ) useraccounts on invswinstalled.component_id = useraccounts.comp_id
  Inner join managedcomputer on invswinstalled.computer_id = managedcomputer.resource_id
  Inner join resource on managedcomputer.resource_id = resource.resource_id
  Inner Join branchmemberresourcerel on branchmemberresourcerel.Resource_ID = Resource.Resource_ID
  Inner Join branchofficedetails on branchmemberresourcerel.BRANCH_OFFICE_ID = branchofficedetails.BRANCH_OFFICE_ID
  where
  managed_status = 61 and (is_usage_prohibited = 2 or invsw.software_id in
  (select invsw.software_id from invmanagedsw
inner join invgroupedsw on invgroupedsw.software_id = invmanagedsw.managed_sw_id
inner join invsw on invsw.software_id = invmanagedsw.software_id
inner join invsw invpsw on invpsw.software_id = invmanagedsw.managed_sw_id
where invpsw.is_usage_prohibited = 2
  ))