Subject Re: [firebird-support] problem with grouping
Author Helen Borrie
At 08:48 PM 24/02/2006, you wrote:
>hi all,
>
>have tables
>user
>--> demand (key userid)
> --> offer (key userid, demandid)
>
>Every offer has price.
>I need to select only best offers (grouped by userid) to a demand.
>Because I must group by all selected rows in FB,
>I cannot use GROUP BY, because I need to select offers' price as well.
>Any ideas?

Of course you can use GROUP BY:

select
d.userid,
max(o.price)
from demand d
join offer o
on o.demandid = d.userid
group by 1

./heLen