Subject | Re: [firebird-support] Help Group by |
---|---|
Author | Richard Wesley |
Post date | 2006-03-15T17:55:46Z |
On Mar 15, 2006, at 09:26, Alberto Pesce wrote:
SELECT o.cod_art, o.order_ID, o.cost
FROM orders o inner join (select cod_art, MIN(cost) as cost from
orders group by cod_art) m ON (m. cod_art = o. cod_art AND m.cost =
o.cost))
This only works with FB2. I'm not sure how you would do this sort of
filtering in FB1, but I maybe you could define the inner query as a
view and join against it? (At least that is what I would try if I
had to make Tableau work with FB1 ;-)
HTH
________________________________________________________
Richard Wesley Software Engineer
Tableau Software
http://www.tableausoftware.com/ hawkfish
tableausoftware com
> I need to obtain a order identificator where cod_art it is at lowerTry something like
> cost.
>
> Thanks
> bye
>
> ----- Original Message -----
> From: "Martijn Tonies" <m.tonies@...>
> To: <firebird-support@yahoogroups.com>
> Sent: Wednesday, March 15, 2006 6:23 PM
> Subject: Re: [firebird-support] Help Group by
>
>
>>
>>
>>> I need to make this query:
>>> the lower cost of product ordered for each oreder.
>>>
>>> this work well
>>>
>>> SELECT cod_art, MIN(cost)
>>> FROM orders
>>> GROUP BY cod_art
>>>
>>> but this return each row in orders
>>>
>>> SELECT order_ID, cod_art, MIN(cost)
>>> FROM orders
>>> GROUP BY order_ID, cod_art
>>>
>>> How can I add order_ID in the first query?
SELECT o.cod_art, o.order_ID, o.cost
FROM orders o inner join (select cod_art, MIN(cost) as cost from
orders group by cod_art) m ON (m. cod_art = o. cod_art AND m.cost =
o.cost))
This only works with FB2. I'm not sure how you would do this sort of
filtering in FB1, but I maybe you could define the inner query as a
view and join against it? (At least that is what I would try if I
had to make Tableau work with FB1 ;-)
HTH
________________________________________________________
Richard Wesley Software Engineer
Tableau Software
http://www.tableausoftware.com/ hawkfish
tableausoftware com