如数据库里有一张表,里面有一个字段有可能为空,也有可能不为空,如何写条sql语句能够将为空的和不为空

的分开,但是是一起查询出来的。也就是说比如把查询结果显示到页面上的时候,最前面是那个字段为空的信息,全部显示完了之后就是那个字段不为空的信息了。

第1个回答  2013-09-13
select *, case isnull(字段) when true then 0 else 1 end as extcol from 表 order by extcol asc
第2个回答  2013-09-13
select * from 表 where 字段 is null
union
select * from 表 where 字段 is not null
第3个回答  2013-09-13
select * from 表 order by 字段名
第4个回答  2013-09-13
用nvl()函数呀
第5个回答  2013-09-13
order by那个字段
相似回答