首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

一个sql语句的写法

2012-03-23 
求助一个sql语句的写法描述表一下。id,postcontent,posttime,replytimes没了。posttime是发布时间。replytime

求助一个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天前的帖子回复量从大到小排序

热点排行