答案 0 :(得分:0)
使用分组依据和子查询
select t.* from
(select subid,status from t t1
group by subid,status
having count(*)>1
) as t1
inner join t on t.subid=t1.subid and t.status=t1.status
答案 1 :(得分:0)
您使用not exists
:
select t.*
from table t
where not exists (select 1 from table t1 where t1.subid = t.subid and t1.status = 'Active');
编辑::如果要获得状态相同的subid
,则可以执行以下操作:
select t.*
from table t
where not exists (select 1 from table t1 where t1.subid = t.subid and t1.status <> t.status);