Try this, Hope this will help you.
declare @t table(aid int, eid int)
insert @t values(1,1)
insert @t values(1,1)
insert @t values(1,1)
insert @t values(1,1)
insert @t values(2,1)
insert @t values(2,1)
select top 1 aid,e from (
select aid,count(eid) e from @t
group by aid) p
order by e desc