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, but wrong results. What is the correct
> query?

Why not use the AVG() function? It does exactly what you want.

  http://dev.mysql.com/doc/mysql/en/GROUP-BY-Functions.html

Jim Winstead
MySQL AB

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to