SELECT id FROM T where o =1 and id in (select id from t where o=2)
вариант два:
select id from (
select id, max(o1) as o1, max(o2) as o2 from (
select id,1 as o1, 0 as o2 from T where o = 1
union
select id,0 as o1, 1 as o2 from T where o = 2
) as T1 group by id
) as T2
where o1=1 and o2=1