Ignore match condition SQL query problem
417599Jan 4 2012 — edited Jan 5 2012create 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.