From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-admin@postgresql.org
Subject: Re: Finding missing values in sequence column
Date: 30 Dec 2010 18:49:49 GMT
Message-ID: <ifik8d$mo8$1@reversiblemaps.ath.cx> (raw)
References: <AANLkTinVg69x_2_E8G2=Q8V5+cduTVzYKSDUzQoTigCh@mail.gmail.com>
On 2010-12-30, Lukasz Brodziak <lukasz.brodziak@gmail.com> wrote:
> Hello,
>
> I have a problem with writing a select statement that would return
> records for which difference in values of this and following ID is
> bigger than 1. Example table
> ID Data
> 1 Text
> 2 Text2
> 5 Text5
> 23 Text23
> 24 TXT
> 25 RRRR
>
> So I need to return rows with IDs 2,5,23.
SELECT id FROM Example EXCEPT SELECT id-1 FROM Example;
select * FROM Example WHERE id+1 NOT IN ( SELECT id FROM Example );
> --
> Łukasz Brodziak
> "What if everyting around You isn't quite as it seems,
> What if all the world You think You know is an inelaborate dream
> When You look at Your reflection is that all you want it to be
> What if You could look right through the cracks
> Would You find Yourself...... Find Yourself afraid to see"
>
--
⚂⚃ 100% natural
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: jasen@xnet.co.nz
Subject: Re: Finding missing values in sequence column
In-Reply-To: <ifik8d$mo8$1@reversiblemaps.ath.cx>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox