SQL|SQL 查找缺失的序号

SELECT D1.digit + (D2.digit*10) AS seq
FROM Digits D1 CROSS JOIN Digits D2
ORDER BY seq;
SELECT D1.digit + (D2.digit10) + (D3.digit100) AS seq
FROM Digits D1 CROSS JOIN Digits D2 CROSS JOIN Digits D3
WHERE seq BETWEEN 1 AND 542
ORDER BY seq;
CREATE VIEW Sequence (seq)
AS SELECT D1.digit + (D2.digit10) + (D3.digit100)
FROM Digits D1 CROSS JOIN Digits D2 CROSS JOIN Digits D3;
CREATE VIEW Sequence (seq)
AS SELECT D1.digit + (D2.digit10) + (D3.digit100) + (D4.digit*1000)
FROM Digits D1 CROSS JOIN Digits D2 CROSS JOIN Digits D3 CROSS JOIN Digits D4;
SELECT seq FROM Sequence WHERE seq BETWEEN 0 AND 4999
EXCEPT
select cast(substr(user_name, 10) as int) as seq from user_info where user_name like ‘test_user%’
【SQL|SQL 查找缺失的序号】参考:
《SQL进阶教程》1.9

    推荐阅读