Subject Re: [firebird-support] Re: Help with query?
Author Milan Babuskov
sbussinger wrote:
>>select client, versionnumber, min(timestamp)
>>from your_table
>>group by client, versionnumber
>
> Thanks Milan! That's close to what I need, but doesn't return the
> speed at which that download occured. Is there any way to get that as
> well?

Sure:

select f.client, f.versionnumber, min(f.ts),
(select speed
from your_table f2
where f2.RDB$DB_KEY = f.RDB$DB_KEY)
from your_table f
group by f.client, f.versionnumber


Please note that this would only work with Firebird. If you want to
write generic SQL statement, I believe you'd need two nested selects.
Something like:


select f.client, f.versionnumber, min(f.ts),
(select first 1 f2.speed
from your_table f2
where f2.client = f.client
and f2.versionnumber = f.versionnumber
and f2.ts = (select min(f3.ts)
from your_table f3
where f2.client = f3.client
and f2.versionnumber = f3.versionnumber)
)
from your_table f
group by f.client, f.versionnumber


If you only need it for Firebird, you should also note that the first
version works much faster.

--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org