Re: [SQL] Aggregates puzzle

2011-04-08 Thread msi77
Try this: select * from flood_ts F join (SELECT lid, MAX(value) AS mvalue, event_id FROM flood_ts GROUP BY lid, event_id) X on F.lid = X.lid and value = mvalue and X.event_id = F.event_id 01.04.2011, 00:15, "Mark Fenbers" : > SQL gurus, > > I have a table with 4 columns:  lid(varchar), value(flo

Re: [SQL] Aggregates puzzle

2011-03-31 Thread Ozer, Pam
Try this. Once you know the value you want you have to join back to find the time of that value. Select f.Lid, F.Value,F.event_id, f.obstime From ( SELECT lid, MAX(value) As Value, event_id FROM flood_ts GROUP BY lid, event_id )sub Join flood f On sub.Value=f.value and f.lid=sub.lid and sub.event