不知道我说清楚了没有,就是想将整个表中的数据按照三个月内的点击率高低排序。我有一个论坛帖子表table1,里面有一年多的数据,我想将这个表的数据排一个序,但是我不想排整个表的,只想根据前三个月的点击率排,三个月内点击率最高的放在最前,就算半年前有更高的点击率也不排到最前面来。请问这样的排序应该怎么实现呢?

解决方案 »

  1.   

    select a.*,row_number()over(partition by dyear,dq order by a.dtime) from 
    (
    select to_char(dtime,'YYYY-MM') dYear,mod(to_char(dtime,'MM'),3)+1 dQ,
    a.* from tb a
    ) a
      

  2.   

    select ID, Title, sContent, CreateUser, CreateDate from view1 case when CreateDate<(sysdate - interval '3' month) then 0 else CTR end DESC, CreateDate DESC我现在是这么写的,想请问这么写对吗?
      

  3.   

    select * from view1 where trunc(createdate+interval '3' month)>trunc(sysdate) order by ctr desc;还真不好猜,不知道这个点击率是否就是这个ctr字段