select a.id from
(select id,
sum(case when status=1 then 1 else 0 end) as shanchu,
count(id) as quanbu
from table group by id)a
where a.shanchu/a.quanbu=1
select T.ID
from T,(select a.ID, min(a.delete_state) as delete_state from a group by a.ID) A
where T.ID = A.ID and A.delete_state = '1'
and T.ID in (...)