Subject | Re: [firebird-support] Re: Help Group by |
---|---|
Author | Adomas Urbanavicius |
Post date | 2006-03-16T10:08:15Z |
Syntax not checked, but idea :
select
orders1.cod_art,
min(MinCost),
( select first 1 orders2.order_id from orders orders2
where
orders2.cod_art = orders1.cod_art order by mincost asc
) ///subselect returns first 1 order_id with cod_art =
order1.cod_art and min(mincost)
from
orders orders1
group by orders1.cod_art;
Adomas
Alberto Pesce wrote:
Pagarbiai / Best Regards,
Adomas Urbanavicius
+37068543336
select
orders1.cod_art,
min(MinCost),
( select first 1 orders2.order_id from orders orders2
where
orders2.cod_art = orders1.cod_art order by mincost asc
) ///subselect returns first 1 order_id with cod_art =
order1.cod_art and min(mincost)
from
orders orders1
group by orders1.cod_art;
Adomas
Alberto Pesce wrote:
>Hi all collaborators,--
> Based on the example I need from table orders
>
> order_ID Cod_art Cost
> -------- ------- ----
> 1 1 10
> 2 2 20
> 3 1 15
> 4 3 20
> 5 3 22
>
>this from the query
>
> Cod_art MinCost order_ID
> ------- -------- ---------
> 1 10 1
> 2 20 2
> 3 20 4
>
>Thank very much
> Bye
>
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Visit http://firebird.sourceforge.net and click the Resources item
>on the main (top) menu. Try Knowledgebase and FAQ links !
>
>Also search the knowledgebases at http://www.ibphoenix.com
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
Pagarbiai / Best Regards,
Adomas Urbanavicius
+37068543336