Count of PC within each OU

For more detail about this query, please see

http://www.windows-noob.com/forums/index.php?/topic/9069-report-count-of-computers-in-certain-organizational-units/

select
    ou.ou,
    count(*) as 'total'
from
    (SELECT sys.ResourceID, max(OU.System_OU_Name0) AS 'OU' FROM dbo.v_R_System AS sys INNER JOIN dbo.v_RA_System_SystemOUName AS ou ON sys.ResourceID = ou.ResourceID GROUP BY sys.ResourceID) ou
group by 
    ou.ou
Order by 
    ou.ou

Leave a Reply

Your email address will not be published. Required fields are marked *