22,210
社区成员
发帖
与我相关
我的任务
分享
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
--哦,忘记条件了。
select top 10 * from ch_news where 日期 between 时间段1 and 时间段2 order by 时间 desc
--楼主可以换个思考方法,就是按照时间倒序排列,取前10条。其实跟你想要的结果是一样的。不过做法就简单的多。
select top 10 * from ch_news order by 时间 desc
select top 10 yourcol from ch_news order by date desc