Simple averaging of table column

This is for a single column, and I don’t want to group - so not using AVG

Want to just average all the numerical values in a column, into a single result.

What is this missing?

$result = "SELECT amounts FROM inventory 
(SUM( inventory.amounts ) / ( COUNT( mysql_num_rows($result))";

Aside from this, what would be needed to get a median value? Divide mysql_num_rows by 1/2 ?

SELECT SUM(amounts) / COUNT(*)
  FROM inventory 

Thanks Rudy.

You probably already know it but for others here. Below gives

Resource id #5

…Without the fetch.

$result = "SELECT SUM(amounts) / COUNT(*) FROM inventory";
$paid = mysql_query($result);
$row = mysql_fetch_array($paid);
$test = $row[0];            [COLOR=#0000ff]// needed for echo

you asked a database question, i gave you a database answer :wink:

if that doesn’t work in your php code, then you need to ask a php question in that form

meanwhile, try assigning a column alias and referencing that (not sure how, because i don’t do php)

SELECT AVG(amounts) [B]AS my_average[/B]
  FROM inventory