result should have only 101,102,104.How to implement this.
So you want to SELECT all rows from your table where there's a record for field B = 'N', and nothing else? And if there is something else, then you don't want to see that record even if there's an 'N' value?
select * from tablename where a in (select a from tablename where b = 'N') and a not in (select a from tablename where b <> 'N')
That'll return duplicates for the records where A = 104, though, so you might want to look at SELECT DISTINCT...
There are almost certainly other ways to do it - some of them may be more efficient. But that should get you started.
16 People are following this question.