Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id C98F31337B7E for ; Thu, 30 Dec 2010 14:51:27 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 24150-09 for ; Thu, 30 Dec 2010 18:51:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtpcorp.com (smtpcorp.com [67.192.120.76]) by mail.postgresql.org (Postfix) with ESMTP id 576431337B43 for ; Thu, 30 Dec 2010 14:51:19 -0400 (AST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpcorp.com; s=main; h=Content-Transfer-Encoding:Content-Type:Mime-Version:References:Message-ID:Date:Subject:From:To; bh=FVQMWbNOFlhHTJCK4g+jzTvG+YFWVUchuFO3873Qi7M=; b=L3czef7mw18hw+/x6IKSL7iVulAO+9j5BqRsGbAJ5PoELq1N8ix9sByg3WmlXbEOrFx6pdNOH8fGEukWGwz7qsgMh2jyxkytGuBv6dwejk+WhWaLU18ot7spnntT/Els; Received: from ip-118-90-141-184.xdsl.xnet.co.nz ([118.90.141.184] helo=gonzo) by smtpcorp.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.70) id 1PYNad-0003DZ-Lb; mid 144 for pgsql-admin@postgresql.org; Thu, 30 Dec 2010 18:51:17 +0000 Received: from news by gonzo with local (Exim 4.72) (envelope-from ) id 1PYNZQ-00064I-9S for pgsql-admin@postgresql.org; Fri, 31 Dec 2010 07:49:52 +1300 To: pgsql-admin@postgresql.org Path: not-for-mail From: Jasen Betts Newsgroups: gmane.comp.db.postgresql.admin Subject: Re: Finding missing values in sequence column Date: 30 Dec 2010 18:49:49 GMT Organization: Dis (not Dat) Organisation Lines: 36 Message-ID: References: NNTP-Posting-Host: localhost Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: reversiblemaps.ath.cx 1293734989 23304 127.0.0.1 (30 Dec 2010 18:49:49 GMT) X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Smtpcorp-Track: 19592127.1.22008244 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201012/209 X-Sequence-Number: 36438 On 2010-12-30, Lukasz Brodziak 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