> 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
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
No comments:
Post a Comment