On Fri, Sep 26, 2008 at 10:39 AM, Steve Midgley <science@misuse.org> wrote:
> drop table if exists dummy;
> create table dummy (
> id integer primary key,
> name varchar(255),
> fkey_id integer
> )
> ;
> The system should return
>
> 502163
> 502164
> 502170
> 502171
--first get all of the duplicated ids
SELECT id FROM Dummy
GROUP BY name, fkey_id
--Next from this list find check to see if there are any sibling
immediate above or below it.
SELECT A.* FROM ( SELECT ID FROM Dummy GROUP BY name, fkey_id ) AS A
INNER JOIN Dummy AS D ON A.id - 1 = D.id OR A.id + 1 = D.id;
--
Regards,
Richard Broersma Jr.
Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug