Re: a JOIN on same table, but 'slided over' - Mailing list pgsql-general

From hubert depesz lubaczewski
Subject Re: a JOIN on same table, but 'slided over'
Date
Msg-id 9e4684ce0706260106p3bd7274n4229519d5afcafac@mail.gmail.com
Whole thread Raw
In response to a JOIN on same table, but 'slided over'  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
Responses Re: a JOIN on same table, but 'slided over'  (Rafal Pietrak <rafal@zorro.isa-geek.com>)
List pgsql-general
On 6/26/07, Rafal Pietrak <rafal@zorro.isa-geek.com> wrote:
Is there an SQL construct to get it?

select
    distinct on (t1.id)
    t1.*, t2.*
from
    test t1
    join test t2 on t2.id > t1.id
order by t1.id asc, t2.id asc

should do the trick.

depesz

--
http://www.depesz.com/ - nowy, lepszy depesz

pgsql-general by date:

Previous
From: Rafal Pietrak
Date:
Subject: a JOIN on same table, but 'slided over'
Next
From: "hubert depesz lubaczewski"
Date:
Subject: Re: data partitions across different nodes