select temp1.*,temp2.usercount
(select * from tb A
where not exists(select 1 from tb where A.username=username and A.addtime<addtime)
)temp1,
(select username,count(*) as usercount from tb group by username)temp2
where temp1.username = temp2.username;