有一个表的数据如下.
------------
a b 1
c d 2
e f 3
我想实现查出来显示在第一行的是第三列为2的数据.
其它按第三列升序排.
也就是实现的效果为下面的样子.
------------
c d 2
a b 1
e f 3
在一个SQL里如何实现?
------解决方案--------------------------------------------------------
select * from table where c3 <> 2 union all (select * from c3=2)
------解决方案--------------------------------------------------------
不用union可能实现不了,你这个也没有什么特性。
楼上的那个,显示的是2在最后一条吧
(select * from c3=2) union all select * from table where c3 <> 2