Subject | Re: [firebird-support] Join three tables problem |
---|---|
Author | Mark Rotteveel |
Post date | 2014-11-27T21:10:27Z |
On 27-11-2014 10:48, ciccios@... [firebird-support] wrote:
http://stackoverflow.com/questions/27168284/join-three-tables-in-firebirdsql
--
Mark Rotteveel
>Just for reference: I answered this question on StackOverflow:
>
> hi to all,
> i have a problem i want join three tables, this is the structure
> (semplified)
>
> Seller
> IdSeller
> NameSeller
>
> BuyFromSeller
> IdBuy
> Qty
> Cost
> FkSeller
>
> Sell
> IdSell
> QtySell
> Price
> FkSeller
>
> i want know all the buy and the sell for seller (if there are)
>
> i have tried
> select
> Seller.NameSeller,
> sum(buyfromseller.qty*buyfromseller.cost) as buys,
> sum(sell.qtysell*sell.price) as Sells,
> from
> Seller
> left join buyfromseller on buyfromseller.fkseller=seller.idseller
> left join sell on sell.fkseller=seller.idseller
> group by
> seller.nameseller
>
> but it turn me doubles values for the sell sum, how can i resolve it?
http://stackoverflow.com/questions/27168284/join-three-tables-in-firebirdsql
--
Mark Rotteveel