Re: a JOIN on same table, but 'slided over'

From: Rafal Pietrak <rafal(at)zorro(dot)isa-geek(dot)com>
To: hubert depesz lubaczewski <depesz(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: a JOIN on same table, but 'slided over'
Date: 2007-06-26 12:28:27
Message-ID: 1182860907.28091.55.camel@zorro.isa-geek.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Marvelous! Thenx!

-R

On Tue, 2007-06-26 at 10:06 +0200, hubert depesz lubaczewski wrote:
> On 6/26/07, Rafal Pietrak <rafal(at)zorro(dot)isa-geek(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gurjeet Singh 2007-06-26 12:35:46 Re: a JOIN on same table, but 'slided over'
Previous Message Kev 2007-06-26 11:36:08 Re: varchar(n) VS text