Report on count of laptops and desktops in each site

Report on count of laptops and desktops in each site

DB Compatibility : PGSQL & MSSQL
Build Compatibility : Builds above 10000

SELECT aaov.NAME AS "Site", case when componentdefinitionlaptop.islaptop is null then 'Desktop' else 'laptop' end as "Workstation type", count(resource.RESOURCENAME) AS "Asset Count" FROM Resources resource
left JOIN ComponentDefinition product ON resource.COMPONENTID=product.COMPONENTID
left join componentdefinitionlaptop on componentdefinitionlaptop.componentid=product.COMPONENTID
left JOIN ComponentType productType ON product.COMPONENTTYPEID=productType.COMPONENTTYPEID
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 where productType.COMPONENTTYPENAME='workstation' group by  aaov.NAME,componentdefinitionlaptop.islaptop