日期:2014-05-17  浏览次数:20665 次

求助一个sql语句的写法
描述表一下。
id,postcontent,posttime,replytimes
没了。
posttime是发布时间。replytimes是回复数量。

需求:返回 最近7天内的帖子按照回复数量从大到小排序后再剩余的全部帖子按照回复数量从大到小排序




------解决方案--------------------
主要看楼主想要的是什么结果
select * from table where posttime>trunc(sysdate)-7 order by replytimes desc
union
select * from table where posttime<trunc(sysdate)-7 order by replytimes desc


结果应该是先列出7天内的帖子回复量从大到小排序,然后再下面列出7天前的帖子回复量从大到小排序