Get records which doesn't have duplicate records I have a table with polcies and class codes, I want to get all policies which doesn't have duplicate class codes. Do you have any idea? One policy may have one or more class codes. If any class code is present for more than one time then I want avoid that policy in the result set.



I need to avoid 23442242 from the result set.
Assuming you just want to avoid the records that're bold:

Setup:

create table simplequestion 
(
 p number,
 c number  
);

insert into simplequestion values (23442242,3455);

insert into simplequestion values (53453453,3454);

insert into simplequestion values (23442242,3455);

insert into simplequestion values (23442242,4567);

insert into simplequestion values (23442242,4667);

insert into simplequestion values (53453453,5656);

insert into simplequestion values (53535354,3543);

insert into simplequestion values (34543545,4354);


Query:

select p,c,count(*)
from simplequestion
group by p,c
having count(*)=1;