add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
CREATE TABLE bustimes (
id int,
"from" int,
"to" int
);

INSERT INTO bustimes VALUES
(18, 33000, 33300),
(19, 33300, 33600),
(20, 33900, 34200),
(21, 34200, 34800),
(22, 36000, 36300);

SELECT * FROM bustimes;
id from to
18 33000 33300
19 33300 33600
20 33900 34200
21 34200 34800
22 36000 36300
SELECT 5
SELECT
id,
lag("to") OVER (ORDER BY id) as prev_to,
"from",
"to",
lead("from") OVER (ORDER BY id) as next_from
FROM bustimes;
id prev_to from to next_from
18 null 33000 33300 33300
19 33300 33300 33600 33900
20 33600 33900 34200 34200
21 34200 34200 34800 36000
22 34800 36000 36300 null
SELECT 5