Friday, 30 September 2011

To find missing value from sequence or sequence like fields


select (a.id + 1)
from tab_name a
where not exists
(select 1
from tab_name b
where b.id = (a.id + 1))
and a.id not in
(select max(c.id)
from tab_namec)
order by 1

No comments:

Post a Comment