Received: from smtpsrv1.isis.unc.edu (smtpsrv1.isis.unc.edu [152.2.1.138]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4GEiJA12029 for ; Wed, 16 May 2001 10:44:19 -0400 (EDT) (envelope-from andrew_perrin@unc.edu) Received: from unc.edu (hpdp111.hpdp.unc.edu [152.2.226.174]) by smtpsrv1.isis.unc.edu (8.9.3/8.9.1) with ESMTP id KAA01083; Wed, 16 May 2001 10:43:21 -0400 (EDT) Message-ID: <3B02920A.B6340FC1@unc.edu> Date: Wed, 16 May 2001 10:43:22 -0400 From: Andrew Perrin X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane CC: Marc Sherman , pgsql-sql List Subject: Re: Select most recent record? References: <17169.990023757@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200105/162 X-Sequence-Number: 2979 Except that he wants max(timestamp) by id; perhaps a GROUP BY would help, something like (untested): select max(timestamp) from log group by id; Tom Lane wrote: > > "Marc Sherman" writes: > > I'd like to select the newest (max(timestamp)) row for each id, > > before a given cutoff date; is this possible? > > select * from log order by timestamp desc limit 1; > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) -- -------------------------------------------------------------- Andrew J. Perrin - Programmer/Analyst, Desktop Support Children's Primary Care Research Group, UNC - Chapel Hill (919)966-9394 * andrew_perrin@unc.edu