Hi, I was hoping I could get some help with a select statement.
I have a log table with three columns: id int4, timestamp datetime,
value int4.
For any given ID, there will be a large number of rows, with
different timestamps and values.
I'd like to select the newest (max(timestamp)) row for each id,
before a given cutoff date; is this possible?
The best I've been able to come up with is the rather ugly (and
very slow):
select * from log as l1 where timestamp in
(select max(timestamp) from log where id=l1.id and
timestamp<'2001-01-01' group by id);
There must be a better way to do this; any tips?
Thanks,
- Marc
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]