Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: Table transform query



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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group