SELECT REPLACE('S' || TO_CHAR(ROWNUM, '000'), ' ', '') AS B
FROM DUAL
CONNECT BY LEVEL <= (SELECT TO_NUMBER(MAX(SUBSTR(A.B, 2))) FROM A)
MINUS
SELECT B FROM A
t第一行写错了maxb,纠正为max_b
with a1 as (select to_number(min(substr(a.b,2,4))) minb,to_number(max(substr(a.b,2,4))) max_b from a),
a2 as (select 'S'||lpad(min_b+level-1) all_b from a1 connect by level<=max_b)
select alln from a2 where not exists (select 1 from a where a.b=a2.all_b) order by 1;
with a1 as (select to_number(min(substr(a.b,2,4))) minb,to_number(max(substr(a.b,2,4))) maxb from a),
a2 as (select 'S'||lpad(min_b+level-1) all_b from a1 connect by level<=max_b)
select alln from a2 where not exists (select 1 from a where a.b=a2.all_b) order by 1;