I recently inherited a database on which one of the tables has the primary key composed of encoded values (Part1*1000 + Part2).
I normalized that column, but I cannot ch
This will give you the complete picture, where 'Bottom' stands for gap start and 'Top' stands for gap end:
select *
from
(
(select +1 as id, 'Bottom' AS 'Pos' from /*where
except
select , 'Bottom' AS 'Pos' from /*where */)
union
(select -1 as id, 'Top' AS 'Pos' from /*where */
except
select , 'Top' AS 'Pos' from /*where */)
) t
order by t.id, t.Pos
Note: First and Last results are WRONG and should not be regarded, but taking them out would make this query a lot more complicated, so this will do for now.