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!

Ignore match condition SQL query problem

417599Jan 4 2012 — edited Jan 5 2012
create table table9(Type1 varchar2(10),Type2 varchar2(10),return_val number);

insert into table9 values('ABC','DEF',1);
insert into table9 values('ABC','Any',2);
insert into table9 values('Any','DEF',3);
insert into table9 values('Any','Any',4);
commit;

I need help in writing a SQL statement which behaves like below

select * from table9 where type1='ABC' and type2='DEF' --It retuns 1
select * from table9 where type1='ABC' and type2='NotDEF' --It should retrun 2
select * from table9 where type1='NotABC' and type2='DEF' -- Should return 3
select * from table9 where type1='NotABC' and type2='NotDEF' --Should return 4

Ideally when i am passing a non-match value to column1(Type1) then it should check the 2nd condition(Column Type2) and return corresponding value. When it finds both non matching values it should return 4.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 2 2012
Added on Jan 4 2012
4 comments
315 views