Sql 给出表(c1)中的一系列数字,找出缺失的数字
给出表C1中的一系列数字,找出缺失的数字。数字应该是连续的Sql 给出表(c1)中的一系列数字,找出缺失的数字,sql,postgresql,gaps-and-islands,Sql,Postgresql,Gaps And Islands,给出表C1中的一系列数字,找出缺失的数字。数字应该是连续的 c1 -- 1 2 3 6 7 8 9 12 14 Expected output: i - 4 5 10 11 13 使用以下系列: 使用以下系列: 面试问题?作业左键将表连接到生成的序列并查找NullsInService问题?作业将表左键联接到生成的序列并查找空值 select s.i from (select generate_series(min(c1), max(c2), 1) as i from t
c1
--
1
2
3
6
7
8
9
12
14
Expected output:
i
-
4
5
10
11
13
使用以下系列:
使用以下系列:
面试问题?作业左键将表连接到生成的序列并查找NullsInService问题?作业将表左键联接到生成的序列并查找空值
select s.i
from (select generate_series(min(c1), max(c2), 1) as i
from t
) s left join
t
on s.i = t.c1
where t.c1 is null;