average in Group By

2004-06-04 Thread Shantanu Oak
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

Re: average in Group By

2004-06-04 Thread Jim Winstead
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

RE: average in Group By

2004-06-04 Thread Kevin Cowley
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