X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DF1B7D78A4 for ; Wed, 24 Aug 2005 20:34:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31737-07 for ; Wed, 24 Aug 2005 23:34:54 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 8AF36D7AC0 for ; Wed, 24 Aug 2005 20:34:52 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7ONYn9c016767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 24 Aug 2005 17:34:52 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7ONYnns018953; Wed, 24 Aug 2005 17:34:49 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7ONYnVZ018952; Wed, 24 Aug 2005 17:34:49 -0600 (MDT) (envelope-from mfuhr) Date: Wed, 24 Aug 2005 17:34:49 -0600 From: Michael Fuhr To: Lane Van Ingen Cc: pgsql-sql@postgresql.org Subject: Re: Can EXCEPT Be Used for To Solve This Problem? Message-ID: <20050824233449.GA12396@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/233 X-Sequence-Number: 22461 On Wed, Aug 24, 2005 at 04:47:16PM -0400, Lane Van Ingen wrote: > Given the following data in a table named 'foo' : > id update_time description > 2 2005-08-24 00:10:00 transaction1 > 2 2005-08-24 00:22:00 transaction2 > 2 2005-08-24 00:34:00 transaction3 > 2 2005-08-24 00:58:00 transaction4 > > I want to select 2nd oldest transaction from foo (transaction 3). The > solution below > works, but I think there may be a better way. Does anyone else have a better > idea? Do you want the 2nd oldest transaction from the entire table? If so then the following should work: SELECT * FROM foo ORDER BY update_time OFFSET 1 LIMIT 1; If that's not what you're after then please elaborate. -- Michael Fuhr