From: | Andrew Perrin <andrew_perrin(at)unc(dot)edu> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Marc Sherman <msherman(at)projectile(dot)ca>, pgsql-sql List <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Select most recent record? |
Date: | 2001-05-16 14:43:22 |
Message-ID: | 3B02920A.B6340FC1@unc.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)projectile(dot)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(at)postgresql(dot)org)
--
--------------------------------------------------------------
Andrew J. Perrin - Programmer/Analyst, Desktop Support
Children's Primary Care Research Group, UNC - Chapel Hill
(919)966-9394 * andrew_perrin(at)unc(dot)edu
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-05-16 14:50:17 | Re: Select most recent record? |
Previous Message | Tom Lane | 2001-05-16 14:35:57 | Re: Select most recent record? |