Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Finding period NOT in a table
"Neff" <fgpsmith_at_gmail.com> schreef in bericht
news:1187705662.328566.212020_at_g4g2000hsf.googlegroups.com...
> Is there an easy way to find which of a set of numbers isn't in a
> table? I'm trying to find financial periods that are missing from a
> set of data. I can do it if I have a table which just contains the
> valid period numbers 1- 12 in the following way:
>
> SELECT
> period_num
> FROM
> valid_periods
> WHERE
> period_num NOT IN (SELECT DISTINCT data_period FROM data_table)
>
> But is there a simple way to do it without the valid_periods table?
>
You'll have to specify in your query what you think are valid periods in
some way....
By using a either a table or hard-coding the numbers in your query (not in
[1..12])
The distinct operator is of no use here (or is it??); and you could use
MINUS in stead of NOT in.
I think a valid periods table is a perfect way to do this.... though I would
use a period number in combination with a year, unless you don't want to run
this query next year.....
Shakespeare Received on Tue Aug 21 2007 - 09:28:14 CDT
![]() |
![]() |