On Thu, 20 Sep 2001, Patrik Kudo wrote:

> On Thu, 20 Sep 2001, Haller Christoph wrote:
> 
> > Try
> > create NEWtable (userid text, val integer, ts timestamp);
> > insert into NEWtable
> > select userid, val, max(ts) from table group by userid, val;
> 
> That won't work. That will give me multiple userid-val combinations. Sure,
> the userid-val combinations will be unique, but I want unique userids
> with only the latest val for each userid.

Maybe something like: (assuming that ts is unique within each userid,
otherwise what does latest mean?  I haven't tried this, so it probably
doesn't parse, but...)

select userid, val from table where ts=(select max(ts) from table t where
 t.userid=table.userid group by userid);


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to