select iproductid, caccount, count(caccount) as cnt, > ( SELECT TOP 1 COUNT(name) > FROM customer c2 > WHERE c2.iproductid = c1.iproductid > AND c2.caccount = c2.caccount > GROUP BY name ORDER BY COUNT(name) DESC) AS AS namecount > from customer c1 > group by iproductid,caccount > having count(caccount)>2 > order by iproductid,cnt>