34,593
社区成员
发帖
与我相关
我的任务
分享
select c.userid,d.username,c.title,c.content
from
(select row_number() over(order by topiccount desc) as rank,userid
from
(select userid,count(*) as topiccount from topic group by userid where addtime<adddate(dd,getdate(),1)) a) b
inner join topic c on b.userid=c.user.id
left outer join user d on b.user_id=d.userid
order by b.rank
select username,
userid,
Title,
Content
from [User] a,Topic b
where a.id=b.userid
order by isnull((select count(*) from Topic where UserID=b.UserID ),0)