Query to show Non IT assets or the assets that does not consume license (MSSQL & PGSQL)

Query to show Non IT assets or the assets that does not consume license (MSSQL & PGSQL)

Tested in Build PGSQL (14300) or MSSQL (14306)

SELECT MAX(resource.RESOURCENAME) AS "Asset Name", MAX(resource.ASSETTAG) AS "Asset Tag", MAX(product.COMPONENTNAME) AS "Product", MAX(productType.COMPONENTTYPENAME) AS "Product Type", MAX(state.DISPLAYSTATE) AS "Asset State", MAX(rtype.TYPE) AS "Asset Type", MAX(deptDef.DEPTNAME) AS "Department", MAX(aaov.NAME) AS "Site", MAX(ad.ORG_NAME) AS "Account" FROM Resources resource LEFT JOIN ComponentDefinition product ON resource.COMPONENTID=product.COMPONENTID LEFT JOIN ComponentType productType ON product.COMPONENTTYPEID=productType.COMPONENTTYPEID LEFT JOIN ResourceType rtype ON productType.RESOURCETYPEID=rtype.RESOURCETYPEID LEFT JOIN ResourceState state ON resource.RESOURCESTATEID=state.RESOURCESTATEID LEFT JOIN ResourceLocation resLocation ON resource.RESOURCEID=resLocation.RESOURCEID LEFT JOIN SiteDefinition siteDef ON resLocation.SITEID=siteDef.SITEID LEFT JOIN SDOrganization aaov ON siteDef.SITEID=aaov.ORG_ID LEFT JOIN ResourceOwner rOwner ON resource.RESOURCEID=rOwner.RESOURCEID LEFT JOIN ResourceAssociation rToAsset ON rOwner.RESOURCEOWNERID=rToAsset.RESOURCEOWNERID LEFT JOIN DepartmentDefinition deptDef ON rOwner.DEPTID=deptDef.DEPTID INNER JOIN AccountSiteMapping asm ON resource.SITEID=asm.SITEID INNER JOIN AccountDefinition ad ON asm.ACCOUNTID=ad.ORG_ID LEFT JOIN ResourceCategory ON productType.RESOURCECATEGORYID=ResourceCategory.RESOURCECATEGORYID WHERE  (((ResourceCategory.CATEGORY like 'Non-IT') AND (rtype.TYPE like 'Asset')) AND (state.RESOURCESTATEID NOT IN (4,5))) GROUP BY resource.RESOURCEID


                    New to ADSelfService Plus?