Subject | Re: [firebird-support] Re: Help with query? |
---|---|
Author | Milan Babuskov |
Post date | 2006-07-23T06:45:42Z |
sbussinger wrote:
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
>>select client, versionnumber, min(timestamp)Sure:
>>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?
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