Hi,
I am trying to find average price of the shares in the
portfolio table.
I thought something like this should work...
SELECT symbol, ((sum(buyrate*quantity))/quantity) as
average
from portfolio group by symbol;
It does work, but wrong results. What is the correct
query?
Shantanu Oak
On Fri, Jun 04, 2004 at 09:25:58AM -0700, Shantanu Oak wrote:
I am trying to find average price of the shares in the
portfolio table.
I thought something like this should work...
SELECT symbol, ((sum(buyrate*quantity))/quantity) as
average
from portfolio group by symbol;
It does work
If buyrate and quantity are per row fields then
SELECT symbol, ((sum(buyrate*quantity))/sum(quantity)) as
average
from portfolio group by symbol;
Kevin Cowley
RD
Tel: 0118 902 9099 (direct line)
Email: [EMAIL PROTECTED]
Web: http://www.alchemetrics.co.uk
-Original Message-
From