Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Marvelous! Thenx! 

-R

On Tue, 2007-06-26 at 10:06 +0200, hubert depesz lubaczewski wrote:
> On 6/26/07, Rafal Pietrak <rafal@xxxxxxxxxxxxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux