发布网友 发布时间:2022-04-23 10:15
共3个回答
热心网友 时间:2022-04-09 09:38
下面是SQL:
SELECT A,B,C FROM 表1
where A=3
ORDER BY C DESC
UNION ALL
SELECT A,B,C FROM 表1
WHERE A<>3
ORDER BY C DESC
进行Union 或者UNION ALL 的 字段必须对应一致
热心网友 时间:2022-04-09 10:56
select A,B,C
from (select 1 _order, A,B,C from 表名 where A=3
union
select 2 _order, A,B,C from 表名 where A<>3) t
order by _order asc, C desc
热心网友 时间:2022-04-09 12:30
select * from tableName where A='3' order by c desc追问那剩下A不等于3的数据呢?我想要这些不等于的数据也显示出来
追答你这个需求恐怕难以实现啊,我这儿没有sqlserver数据库不能测试,你试试这句看
select * from tableName where A='3' order by c desc
union
select * from tableName where id not in (select * from tableName where A='3' )