use group by and sub-query
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
You use not exists
:
select t.*
from table t
where not exists (select 1 from table t1 where t1.subid = t.subid and t1.status = 'Active');
EDIT : If you want to get the subid
s which have same status then you can do :
select t.*
from table t
where not exists (select 1 from table t1 where t1.subid = t.subid and t1.status <> t.status);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.