Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of 2 group functions?

Status
Not open for further replies.

vbkris

Programmer
Jan 20, 2003
5,994
IN
hi,

when i use this it gives me an error:

select max(avg(field1)).....

is there a better way to pick the data. i am forced to use MySql 3.x version (cause thats whats there on the server!!!)

Known is handfull, Unknown is worldfull
 
You would have to first get the AVG() results, store them in a temporary table, then get the MAX():
[tt]
CREATE TEMPORARY TABLE t AS
SELECT AVG(field1) a FROM tbl1;
SELECT MAX(a) m FROM t;
[/tt]
 
Of course, the AVG() query would have to grouped:
[tt]
CREATE TEMPORARY TABLE t AS
SELECT AVG(field1) a
FROM tbl1
GROUP BY field2;
SELECT MAX(a) m FROM t;
[/tt]
 
thanks buddy...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top