用sql语句查询没有连续的字段 如 字段内容为 1,2,3,5,8,11 则输出 4,6,7,9
思路:构建字段序列, 如 从1到11的序列;查询缺失的序列;1234567891011121314151617--基础数据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 allselect s_id 1,e_id from tmp1where...全部
思路:构建字段序列, 如 从1到11的序列;查询缺失的序列;1234567891011121314151617--基础数据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 allselect s_id 1,e_id from tmp1where s_id 收起