Re: a JOIN on same table, but 'slided over'
| От | PFC |
|---|---|
| Тема | Re: a JOIN on same table, but 'slided over' |
| Дата | |
| Msg-id | op.tuirzoemcigqcu@apollo13 обсуждение исходный текст |
| Ответ на | a JOIN on same table, but 'slided over' (Rafal Pietrak <rafal@zorro.isa-geek.com>) |
| Список | pgsql-general |
> Now, I'd like to make a JOIN-ed query of that table with itself, so that
> I'd get rows paiwise: every row containing data from *two* rows of the
> original TEST table so, that those data come from rows of consequtive
> ID's - not neceserly (depending on the TEST table contents) continuesly
> consequtive. Like:
>
> SELECT * from view_of_test;
> id | id+X | thread | thread+X | info | info+X
> ----+------+--------+----------+-------+---------
> 2 | 3 | 763 | 764 | A | B
> 3 | 6 | 764 | 5 | B | C
> 6 | 8 | 5 | 88946 | C | Cats
> 8 | 9 | 88946 | 69315 | Cats | Eifel
> 9 | 10 | 69315 | 96379 | Eifel | G
> -------------------------------------------------
> Is there an SQL construct to get it?
I would use a plpgsql procedure, select all the rows ORDER BY id, keep
the current and last row in a variable, and that's it.
В списке pgsql-general по дате отправления: