troubleshooting Question

Find average of max values - mysql

Avatar of shafer23
shafer23Flag for United States of America asked on
Microsoft SQL ServerPHP
3 Comments1 Solution447 ViewsLast Modified:

I have a routine that returns the max value of each group of records, roughly something as follows:

SELECT max (price) FROM product GROUP BY productcategory;

so, this will return the max price with respect to each product category.  I am actually interested in the average of such max prices.

I would think that there should just be a way to take the average of such results within a mysql statement, but that does not seem to be the case; instead, it seems as though I need to loop through records and calculate the sum and divide it by the recordcount.

Am I missing any obvious solutions?

Kent Olsen
Data Warehouse / Database Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros