Bug #4871 MAX(COUNT(*))...GROUP BY
Submitted: 3 Aug 2004 14:45 Modified: 4 Aug 2004 10:12
Reporter: Mickael Besson Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.3 OS:Windows (Windows NT4)
Assigned to: CPU Architecture:Any

[3 Aug 2004 14:45] Mickael Besson
Description:
The command :
select att1, MAX(COUNT(*)) from t group by att1;
 doesn't run, and it will be usefull to use it.

How to repeat:
select att1, MAX(COUNT(*)) from t group by att1;
[4 Aug 2004 10:12] Marko Mäkelä
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

MAX() and COUNT() are aggregate functions that operate on sets and return a single item. Why doesn't COUNT(*) alone work for you? Please read the documentation. If you still think that there is an error, submit a complete repeateable test case, including statements for creating and populating the table.
[4 Aug 2004 21:48] Peter Gulutzan
mysql> create table t (attr1 int); 
Query OK, 0 rows affected (0.52 sec) 
 
mysql> insert into t values (1),(2),(2),(3),(3),(3),(NULL); 
Query OK, 7 rows affected (0.00 sec) 
Records: 7  Duplicates: 0  Warnings: 0 
 
mysql> select attr1,max(attr1_count) from (select attr1 as attr1, count(*) as attr1_count 
from t group by attr1) as t group by attr1; 
+-------+------------------+ 
| attr1 | max(attr1_count) | 
+-------+------------------+ 
|  NULL |                1 | 
|     1 |                1 | 
|     2 |                2 | 
|     3 |                3 | 
+-------+------------------+ 
4 rows in set (0.00 sec)