personally, i love the integer table, and have no qualms about generating one in any database i'm working on as soon as the need comes up
after all, it comes in handy in all sorts of queries, and once you've declared the integers table, you can just use it
if necessary, when you get a problem that requires very many integers, if you're not sure how many you have, you can just SELECT MAX(i) FROM INTEGERS to see if you need to add more
create table integers
( i integer primary key );
insert into integers (i) values (0);
insert into integers (i) values (1);
insert into integers (i) values (2);
insert into integers (i) values (3);
etc.
now this table can easily be brought into use in many different situations
for one example, see
in your case, numbers that don't have a name, i.e. numbers that aren't in your table, you need an outer join --
select NUMBER
from integers
left outer
join yourtable
on i=NUMBER
where i between 1 and 10
and NUMBER is null
i can explain that if you want me to
yes, you can also do it by generating the numbers "on the fly" as it were
i don't know about oracle, but in sql/server you can say
select 1
union
select 2
union
etc.
select 10
and then use this query as a derived table basically by just wrapping parentheses around it, giving it an alias, and then sticking it into the query above in place of the integers table
in oracle you could select from dual, which is only minimally more verbose
in other databases you'd have to invent a one-row table just like dual, so rather than select from it 10 times, you'd be better off to create the integers table and forget about that ugly UNION (imagine doing that for i=25, i=50,...)
which is why i like the integers table
rudy