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

Re: Finding sequential records

From: "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com>
To: "Steve Midgley" <science(at)misuse(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org, oliveiros(dot)cristina(at)marktest(dot)pt
Subject: Re: Finding sequential records
Date: 2008-09-27 01:08:35
Message-ID: 396486430809261808g4565d6c9l4fd1b98a2ab900e7@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
On Fri, Sep 26, 2008 at 3:25 PM, Steve Midgley <science(at)misuse(dot)org> wrote:

> This returns an error:
>
> ERROR: column "dummy.id" must appear in the GROUP BY clause or be used in an
> aggregate function
> SQL state: 42803

Oops that what I get for trying air code :(

This works instead:

SELECT D1.*
      FROM Dummy AS D1
INNER JOIN Dummy AS D2
        ON (D1.name,D1.fkey_id)=(D2.name,D2.fkey_id)
       AND (D1.id = D2.id + 1 OR D1.id = D2.id - 1 )
ORDER BY D1.id;


-- 
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

In response to

pgsql-sql by date

Next:From: Steve MidgleyDate: 2008-09-30 02:48:09
Subject: Re: Finding sequential records
Previous:From: Oliveiros CristinaDate: 2008-09-27 00:38:08
Subject: Re: Finding sequential records

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group