select servername, sitecode, count(distinct name0) ‘clients’
from ProtectedSiteSystem_ARR PSS join v_BoundaryInfo bound on pss.BoundaryID=bound.BoundaryID join v_RA_System_IPSubnets subs on subs.IP_Subnets0=bound.value join v_R_System sys on sys.resourceID=subs.resourceID
where client0=1 and obsolete0=0
group by servername, sitecode
order by count(*) desc