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!

find unused number within a range using just SQL

user13118348Oct 14 2011 — edited Oct 14 2011
Hi everyone,

I have an Oracle table that holds random numbers within a specific range. Consider the following example:

Table A has only 1 column and it holds the following data

TABLE A
2
3
4
7
8
9

I need to write a query to provide me numbers that DO NOT exist in this table and that are within range of 1-10. So the result of this query would be

1
5
6
10

I want to do this using just SQL. I know I can do this easily using a while loop to populate a temp table with values from 1 to 10 and then just use minus. But I dont want to do that.

Also keep in mind that above is just an example, in reality these numbers are huge.

Any ideas?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 11 2011
Added on Oct 14 2011
5 comments
2,561 views