日期:2014-05-17 浏览次数:20618 次
select top 10 m.* , count(1) 回复次数 from 帖子表 m , 回复表 n where m.Tid = n.Tid and datediff(hh,n.CreatTime,getdate()) <= 24 order by 回复次数 desc
select top 10 m.* , count(1) 回复次数 from 帖子表 m , 回复表 n where m.Tid = n.Tid and datediff(dd,n.CreatTime,getdate()) <= 1 order by 回复次数 desc
select
top 10 *
from
(select id,count(1) as 发帖次数 from 帖子表 where datediff(hh,createtime,getdate())<24 group by id)a,
(select id,count(1) as 回复次数 from 回复表 where datediff(hh,createtime,getdate())<24 group by id)b
where
a.id=b.id
order by
b.回复次数 desc
select
top 10 a.tname
from
帖子表 a,(select tid,count(1) as 回复次数 from 回复表 group by tid)b
where
a.tid=b.tid
and
datediff(hh,CreatTime,getdate())<=24
order by
b.回复次数 desc
select
top 10 a.tname
from
帖子表 a,(select tid,count(1) as 回复次数 from 回复表 group by tid)b
where
a.tid=b.tid
and
datediff(hh,CreatTime,getdate())=24
order by
b.回复次数 desc
select
top 10 *
from
(select id,count(1) as 发帖次数 from 帖子表 group by id)a,
(select id,count(1) as 回复次数 from 回复表 group by id)b
where
a.id=b.id
order by
b.回复次数 desc