From: Andrew Perrin <andrew_perrin@unc.edu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Marc Sherman <msherman@projectile.ca>
Cc: pgsql-sql List <pgsql-sql@postgresql.org>
Subject: Re: Select most recent record?
Date: Wed, 16 May 2001 10:43:22 -0400
Message-ID: <3B02920A.B6340FC1@unc.edu> (raw)
References: <CGEPKMKAIFJINAOACFFEOEJDCGAA.msherman@projectile.ca>
<17169.990023757@sss.pgh.pa.us>
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" <msherman@projectile.ca> 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
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-sql@postgresql.org
Cc: andrew_perrin@unc.edu, tgl@sss.pgh.pa.us, msherman@projectile.ca
Subject: Re: Select most recent record?
In-Reply-To: <3B02920A.B6340FC1@unc.edu>
* 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