我想做一个论坛
数据库中有一个记录点击的表
在这个表里有这么两个字段topicId      -- 这个字段是指点击了哪个帖子的ID
clickTime  -- 点击时间表的内容大致如下:id clickTime
1 2010.1.1
1 2010.2.1
2 2010.1.3
1 2010.1.3
3 2010.1.5
1 2010.1.1
1 2010.1.3
3 2010.1.1
2 2010.1.3
3 2010.1.2我就是想做一个本周点击量最大的帖子排序排序后结果为:
本周点击量最高的帖子为:
排名 帖子ID
1 1 -- 点击过5次
2 3 -- 点击过3次
3 2 -- 点击过2次

解决方案 »

  1.   

    select topicId from table_list where max
    (select count(topicId) from table_list) 
    and group by topicId
      

  2.   


    SELECT id,'点击过'+convert(varchar(10),count(clickTime))+'次'
    FROM [dbo].[TABLE1] where datepart(wk,clickTime)=datepart(wk,getdate())
    group by id
    order by count(clickTime) desc看看这样能不能帮助你
      

  3.   

    谢谢 二楼的 wonderful131 已经成功执行 十分感谢 也感谢一楼的回复 结帖