Re: SQL Query
Date: Fri, 18 Oct 2002 00:40:48 GMT
Message-ID: <kMIr9.87571$oq6.23754_at_sccrnsc01>
Do you consider sub-queries temporary tables? If not, then here you go....
select B.Currency,
Buy_Amount, Sell_Amount from (select Buy_Currency as Currency, SUM(Buy_Amount) as Buy_Amount from A group by Buy_Currency) B, (select Sell_Currency as Currency, SUM(Sell_Amount) as Sell_Amount from A group by Sell_Currency) C
where B.Currency = C.Currency
group by B.Currency,
Buy_Amount, Sell_Amount;
"gavs" <gavspp_at_yahoo.com> wrote in message
news:54dc4b2a.0210160800.64c6c327_at_posting.google.com...
> Hello:
>
> I need help with formulating a sql query without using temporary tables:
>
> table A contains the following columns:
>
> buy_currency sell_currency buy_amount sell_amount
> JPY USD 100. 1.00
> USD JPY 2.00 200.
>
>
> The final answer should be:
> currency buy_amt sell_amt
> JPY 100. 200.
> USD 2.00 1.00
>
> The actual query will be a sum of all currencies grouped by currency.
>
> Any suggestions will be helpful.
>
> Thanks.
> AG
Received on Fri Oct 18 2002 - 02:40:48 CEST