List:General Discussion« Previous MessageNext Message »
From:walter harms Date:July 24 2008 4:14pm
Subject:Re: how to optimize: max(timetstamp) where a.foo=b.foo ?
View as plain text  

Peter Brawley wrote:
>> to get the latest value for each id i have queries like:
> 
>> select * from tab A where timestamp = (select max(timestamp) from tab
>> B where B.id=A.id) group by id ;
> 
> See "Within-group aggregates" at
> http://www.artfulsoftware.com/infotree/queries.php.
> 
> PB
> 

hi peter,
txh for your hint,
is seems that the "join .. on" stuff works fine.

the most tricky part was to realize that max(timestamp) as foo was need
so the result could be used with join, (took me 3 sec to find :) )

re,
 wh


Thread
how to optimize: max(timetstamp) where a.foo=b.foo ?walter harms24 Jul
  • Re: how to optimize: max(timetstamp) where a.foo=b.foo ?Mr. Shawn H. Corey24 Jul
  • Re: how to optimize: max(timetstamp) where a.foo=b.foo ?Peter Brawley24 Jul
    • Re: how to optimize: max(timetstamp) where a.foo=b.foo ?walter harms24 Jul