這樣不行了
select * from table where isnull(optime,'')=''
union all
select * from table where isnull(optime,'')<>'' order by id desc
select * from table where isnull(optime,'')=''
union all
select * from table where isnull(optime,'')<>'' order by id desc
union
select * from table where optime is not null order by id desc
OPTIME的排序就和之前ID一样,是乱的,空的和不为空的混合着的!!
order by (case when optime is null then 0 else 1 end),optime,id desc
from 表
order by case when optime is null then optime else id end
虽然我还没去试,但是为什么要在optime上处理,因为只是id的问题啊!
(case when optime is null then 9999999 else id end) desc