你没说清楚啊,你目前描述的先按时间排序,选择TOP 10就行了!select top 10 yourcol from ch_news order by date desc

解决方案 »

  1.   


    --楼主可以换个思考方法,就是按照时间倒序排列,取前10条。其实跟你想要的结果是一样的。不过做法就简单的多。
    select top 10 * from ch_news order by  时间 desc
      

  2.   


    --哦,忘记条件了。
    select top 10 * from ch_news where 日期 between 时间段1 and 时间段2 order by  时间 desc
      

  3.   

    不好意思,可能有点着急了,没说清楚了
    表为ch_news,查询的条件为
    (times-添加时间,hits-点击率)
    1.首先返回10条30天内的记录,根据hits排序
    2.如果记录数不足10条,再根据点击率自动补充以达到10条记录.
      

  4.   


    use [yourdatabase]
    select * into #tb1 from ch_news where times>=DATEADD(day, - 30, GETDATE()) order by hits desc
    select * into #tb2 from ch_news where times<DATEADD(day, - 30, GETDATE()) order by hits desc
    select top 10 * from ((select * from #tb1) union all (select * from #tb2))tb
    drop table #tb1,#tb2
    这样应该可以吧!测试下看看!