Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Excluding records which meet a criteria.

tbhluehornSep 8 2016 — edited Sep 24 2016

Please  help me construct a query which  can exclude records which meet a criteria.
I will try to describe the exact behavior I need,  I want to exclude records which have fields with certain values.

------Create my  table.

create table TABLE_NAME

(

CustomerID varchar(20),

COLOUR01 varchar(6),

COLOUR02 varchar(6),

COLOUR03 varchar(6))  

---------insert values

Insert into TABLE_NAME (CustomerID,COLOUR01,COLOUR02,COLOUR03) values ('1','RED','GREEN','BLUE');

Insert into TABLE_NAME (CustomerID,COLOUR01,COLOUR02,COLOUR03) values ('2','RED','GREEN','BLUE');

Insert into TABLE_NAME (CustomerID,COLOUR01,COLOUR02,COLOUR03) values ('3','GREEN','GREEN','GREEN');

Insert into TABLE_NAME (CustomerID,COLOUR01,COLOUR02,COLOUR03) values ('4','ORANGE','GREEN','YELLOW');

Insert into TABLE_NAME (CustomerID,COLOUR01,COLOUR02,COLOUR03) values ('5','ORANGE','GREEN','YELLOW');

Insert into TABLE_NAME (CustomerID,COLOUR01,COLOUR02,COLOUR03) values ('6','ORANGE','GREEN','VIOLET');

Insert into TABLE_NAME (CustomerID,COLOUR01,COLOUR02,COLOUR03) values ('7','ORANGE','GREEN','VIOLET');

-----------Create query to exclude records which have COLOUR01=RED ,  COLOUR02=GREEN, and COLOUR03=BLUE

-----------I need to exclude the first two records, The logic needed is as follows if  there is a record that has COLOUR01=RED ,  COLOUR02=GREEN, and COLOUR03=BLUE then exclude the record.

-----------Records 3 through  7  should be the results of the query.

Any suggestions will be greatly appreciated I am really breaking my head over this!  TY

This post has been answered by mathguy on Sep 8 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 22 2016
Added on Sep 8 2016
15 comments
1,701 views