b.flag,c.flag为b,c表中的其他一个字段select a.id,decode(b.flag,null,decode(c.flag,null,'a not in b and c','a in c'),'a in b')
from a,b,c
where a.id = b.id(+)
  and a.id = c.id(+)