Hi Pols,
Try this code
create table #ABC
(
id1 int,
count1 int
)
insert into #ABC values (1,10)
insert into #ABC values (1,20)
insert into #ABC values (1,30)
insert into #ABC values (1,40)
insert into #ABC values (2,10)
insert into #ABC values (2,20)
insert into #ABC values (2,30)
insert into #ABC values (3,40)
insert into #ABC values (3,5)
select a.* from #ABC a
where a.count1 in (select top 2/*plot your count top 1,2,3..*/ b.count1 from #ABC b where b.id1 = a.id1)
order by a.id1,a.count1 /*if needed use the order*/
ARUN SAS