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
sub.event_id=v.event_id -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Mark Fenbers Sent: Thursday, March 31, 2011 1:15 PM To: PostgreSQL - SQL Subject: [SQL] Aggregates puzzle SQL gurus, I have a table with 4 columns: lid(varchar

[SQL] Aggregates puzzle

2011-03-31 Thread Mark Fenbers
SQL gurus, I have a table with 4 columns: lid(varchar), value(float), obstime(datetime), event_id(integer) I want to find the MAX(value) and the time and date that it occurred (obstime) in each group of rows where the lid and event_id are the same. What I have works correctly in identifyin