Initial input:
CREATE TABLE TEST_TABLE(
start_i INT,
end_i INT,
v REAL
);
INSERT INTO TEST_TABLE (start_i, end_i, v)
VALUES (300,305,0.5),
(313,316,0.25)
start_i | end_i | v |
---|---|---|
300 | 305 | 0.5 |
313 | 316 | 0.25 |
Desired outcome:
Basically, I want to create intermediate rows with an additional column containing each value in the ranges shown in the initial table.
i | start_i | end_i | v |
---|---|---|---|
300 | 300 | 305 | 0.5 |
301 | 300 | 305 | 0.5 |
302 | 300 | 305 | 0.5 |
303 | 300 | 305 | 0.5 |
304 | 300 | 305 | 0.5 |
305 | 300 | 305 | 0.5 |
313 | 313 | 316 | 0.25 |
314 | 313 | 316 | 0.25 |
315 | 313 | 316 | 0.25 |
316 | 313 | 316 | 0.25 |
I have checked this post, but it's for SQL Server, while I am interested in Postgres. In addition, I am not using a date column type, but an integer instead.