select * 
from (select count(hitid) as hits,customerid 
     from hit group by customerid) as HitC,
     customer C
where C.CustomerID = HitC.CustomerID
order by hits desc;
