思路:
构建字段序列, 如 从1到11的序列;
查询缺失的序列;
--基础数据
with tmp as
(select 1 as id union all
select 2 union all
select 3 union all
select 5 union all
select 8 union all
select 11 ),
--构建序列
tmp1 (s_id,e_id) as
(select min(id),max(id) from tmp
union all
select s_id+1,e_id from tmp1
where s_id--查询缺失的序列
select s_id from tmp1 where s_id not in (select id from tmp)
order by s_id;