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!

Select query with combination of two columns

985847Jan 25 2013 — edited Jan 27 2013
I need looking to write a nested select statement that would achieve the following.
Support i have a table as follows
TestTable
Name : Age : Country
Test1 : 10 : USA
Test2 : 11 : USA
Test3 : 12 : USA
Test4 : 11 : Canada
Test5 : 12 : Canada

Now i want to select from the above table the following information.
Get all the names of people who dont belong to this combinations (10:USA,11:Canada,12:Canada). The list can be huge.
The result should be
Test1:10:USA
Test1:12:USA

If it were one combination i can write
select * from TestTable
where age <> 10 and country <>Canada

Also i can also do
select * from TestTable
where age NOT IN (10,11) and country NOT IN (USA,COUNTRY)
But i don't this it would give me correct result.
This post has been answered by Stew Ashton on Jan 26 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2013
Added on Jan 25 2013
15 comments
4,022 views