-
Hi,
Can any one help me in finding missing no.s in a column
USING SINGLE SQL .
For eg column a contains 1,3,6,10
I want the answer as 2,4,5,7,8,9
-
You can use either of the 2 sql's
1)select nvl(max(a.t),0) + 1 gapfrom,b.t-1 gapto
from temp a ,temp b
where a.t(+) < b.t
group by b.t having nvl(max(a.t),0) < b.t -1;
2) select a.t +1,b.t -1 from temp a,temp b where
a.t +1 not in(select t from temp) and
b.t=(select min(t) from temp where t > a.t)
Cheers
-
Here is another simple solution.
select rownum from tab
where rownum <= ( select max(x) from your_table )
minus
select x from your_table
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|