Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: HELP !!! SQL GURUS !!!! How do I do this ???
Jens U. Veigel wrote:
>
> Hey Pro's
>
> Got a problem.
>
> I'm trying to slelect a column which has numbers in it lets say 1
> through 5, and compare it to a list of known values.
> Lets say 1 through10.
> I would like it to come back with all the matching numbers that are
> not in the column such as 6,7,8,9,10.
>
> I was trying somthing like this:
>
> select column
> from table
> where column is not in
>
> (select column from
> table
> where column is in ('1','2','3','4','5','6','7','8','9',10')
>
> then it returns 1,2,3,4,5
>
> what I need it to return is 6.7,8,9,10
> (the exact opposite)
>
> It seems so simple, what am I doing wrong ??
> Thanks for reading it !
>
> Jens
>
> jens_at_deutschware.com
>
Jens,
The easiest way to do this is to use the MINUS keyword in SQL
You create 2 tables - TEST and TEST2.
TEST would contain your list of allowable values (1,2,3,4,5,6,7,8, 9,10)
TEST2 would contain the partial set of values (1,2,3,4,5)
The SQL Statement would look something like this:
select num from test MINUS select num from test2;
The result is 6,7,8,9,10 - just like a math problem.
Nathan
nsecrist_at_evolving.com Received on Tue Apr 01 1997 - 00:00:00 CST
![]() |
![]() |