tags:

views:

104

answers:

2

I'm wondering if in MySQL you are able to find a range within values along with the average in a query. Assume the table below please:

-----------------------------------------
|     ID         |         VALUE        |
-----------------------------------------
|     1          |          30          |
-----------------------------------------
|     2          |          50          |
-----------------------------------------
|     3          |          10          |
-----------------------------------------

Range Low would be 10, range High would be 50, average would be 30.

Is there query that would allow me to grab these values without pulling them down into php and then sorting the array, and finding the average that way?

Cheers

+4  A: 
SELECT Avg(Value), Max(Value), Min(Value) FROM tableName

See also MySQL Aggregate Functions

Matt Bridges
Thank you for your quick response. Didn't know there were canned functions! Cheers!
Frederico
+2  A: 

Is this what you want?

select min(value) as low, max(value) as high, avg(value) from table_name
Virat Kadaru