dcsimg
Results 1 to 3 of 3

Thread: SQL max(mean(*)) how to do it ?

  1. #1
    Join Date
    Jul 2008
    Posts
    1

    Red face SQL max(mean(*)) how to do it ?

    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!

  2. #2
    Join Date
    Jul 2008
    Location
    Belgium
    Posts
    17
    Hello


    Try this.

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


    Greetings
    ld_be

  3. #3
    Join Date
    Apr 2009
    Posts
    1

    Think so this also may work

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •