select * from table t where t.hospital_expire_flag=1
union all
select 表字段 from
(
select t.*, rank()over(order by 升序 desc) rn from table t where t.hospital_expire_flag=0
) t1 where t1.rn=1
这个我知道的就是分开做
(select distinct(subject_id)from table where hospital_expire_flag = 1) union ( select distinct(subject_id)from table where hospital_expire_flag = 0 order by 升序 desc )
降序可以使用吗
你这个 **升序 ** 字段 是查询出来的 还是表结构里面就有这个字段