日期:2014-05-18 浏览次数:20447 次
--求24小时评论排行榜(只要前3条数据) select top 3 row_number() over(order by getdate()) '排名', a.gno '商品编号',b.title '商品名',a.ct '评论数' from (select gno,count(*) ct from Subjects where comType='评论' and poState='通过' and datediff(hh,poDate,getdate())<=24 group by gno ) a inner join Goods b on a.gno=b.gno order by a.ct desc --求7天评论排行榜(只要前3条数据) select top 3 row_number() over(order by getdate()) '排名', a.gno '商品编号',b.title '商品名',a.ct '评论数' from (select gno,count(*) ct from Subjects where comType='评论' and poState='通过' and datediff(d,poDate,getdate())<=7 group by gno ) a inner join Goods b on a.gno=b.gno order by a.ct desc