Re: Table transform query

From: Rodrigo De León <rdeleonp(at)gmail(dot)com>
To: "Philippe Lang" <philippe(dot)lang(at)attiksystem(dot)ch>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Table transform query
Date: 2007-09-18 13:51:17
Message-ID: a55915760709180651p4df78cfm59dc219bdd6729ce@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 9/18/07, Philippe Lang <philippe(dot)lang(at)attiksystem(dot)ch> wrote:
> ... into this:
>
>
> serial dateL dateR
> --------------------
> 1 1 2
> 1 4
> 2 1 2
> 3 1 3
> 4 2 3
> 5 3

SELECT t1.serial, t1.DATE AS datel, t2.DATE AS dater
FROM t t1 LEFT JOIN t t2 ON( t1.serial = t2.serial
AND t1.DATE < t2.DATE)
WHERE t1.delivery = 'L'
AND ( t2.delivery = 'R'
OR t2.delivery IS NULL)
ORDER BY t1.serial

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-09-18 15:13:10 Re: error dropping operator
Previous Message Philippe Lang 2007-09-18 13:49:47 Re: Table transform query