select
*
from
(
select
e.name
,p.id
,row_number() OVER (PARTITION BY p.follower_id ORDER BY p.id) [rank]
from p_case p with(nolock)
join employee e on e.id=p.follower_id
) t where t.[rank]<=400
select rs.id,e.name
from employee e
CROSS APPLY
( select
top 400 p1.id, case_count
from p_case p1 with(nolock)
where e.id=p1.follower_id
) rs