比如置顶为1,非置顶为0
select
*
from
(select
*
from
bbs
order
by
ctime
desc)
c
order
by
istop
desc
1.先查询出按时间倒序结果集
2.在上一个结果集中查询按置顶倒序的结果集
一般的做法是分2部分做的.首先读取出isTop=true的记录按置顶时间排序 循环
然后再读取出isTop=false 然添加时间排序 循环..这样说 你明白了吗?
试验了一下下面这个可以:oracle:
select t.id,t.tname,t.tdate from teacher t left join consume c on t.id=c.tid order by c.id,tdate desc
select t.id,t.tname,t.tdate from teacher t left join consume c on t.id=c.tid order by nvl(c.id,9999999),tdate desc
sqlserver:
select t.id,t.tname,t.tdate from teacher t left join consume c on t.id=c.tid order by isnull(c.id,9999999),tdate desc
*****************************************************
补充:
access:
SELECT t.id, t.tname, t.tdate
FROM teacher AS t LEFT JOIN consume AS c ON t.id=c.tid
ORDER BY iif(isnull(c.id),999999,c.id), tdate DESC
*****************************************************
---
以上,希望对你有所帮助。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)