By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE table_name
(`a` int)
;
INSERT INTO table_name
(`a`)
VALUES
(1),
(4),
(8),
(9)
;
select * from
(select lead(a) over(order by a) - a as a
from table_name) t
where a is not null;
a |
---|
3 |
4 |
1 |