2008/10/17 dave aptiva <[EMAIL PROTECTED]>:
>
> I tried SELECT ID_number, max( count( CU_number ) ) but this causes an error
> "#1111 - Invalid use of group function "


# sqlite3
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> create table moo (id_number, cu_number);
sqlite> insert into moo(1, 1);
SQL error: near "1": syntax error
sqlite> insert into moo values (1, 1);
sqlite> insert into moo values (1, 2);
sqlite> insert into moo values (1, 3);
sqlite> insert into moo values (2, 3);
sqlite> SELECT id_number, count(cu_number) FROM moo GROUP BY id_number;
1|3
2|1
sqlite> SELECT id_number, count(cu_number) FROM moo GROUP BY id_number
HAVING count(cu_number) = max(cu_number);
1|3



OR:

sqlite> SELECT id_number, count(cu_number) FROM moo GROUP BY id_number
ORDER BY count(cu_number) DESC LIMIT 1;
1|3

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to