select top 10 ID,USERNAME, TITLE, TIME
from
(select *,row_number()oveer(partition by USERNAME order by ID) as cnt
from table) As A
where cnt <=2
order by TIME DESC
from
(select *,row_number()oveer(partition by USERNAME order by ID) as cnt
from table) As A
where cnt <=2
order by TIME DESC
from table where username in (select username from table A group by username having count(*)> 1)
where not exists(
select * from tb where username=t.username and id<=t.id
group by username having count(*)>2
)把tb改成你的表名