# Related Sites > SQL Course >  SQL max(mean(*))  how to do it ?

## mistermads

Total newbie here. How can I get the MAX of the AVG?

Here's how I can get the mean...

SELECT AVG(x),par1,par2 FROM results GROUP BY par1,par2,par3;

Then I want the MAX of that across par3. The following does not compute, but could perhaps help to explain what I want...

SELECT MAX(AVG(x)),par1,par2 FROM ?the-query-above? GROUP BY par1,par2;

?  but how?   I have tried to look into subqueries... I just have problems moving from sequential programming... heeeeelp!  :Embarrassment:

----------


## ld_be

Hello


Try this.

SELECT MAX(avgpar3)
FROM (SELECT AVG(par3) AS avgpar3
          FROM results
          GROUP BY par1, par2) AS avgresults


Greetings
ld_be

----------


## nightmare

SELECT avgpar3
FROM (SELECT AVG(par3) AS avgpar3
FROM results
GROUP BY par1, par2) where max(avgpar3)=avgpar3

----------

