亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

MySQL operation to get maximum sum function
P粉139351297
P粉139351297 2024-04-04 17:49:26
0
1
685

I'm trying to set the maximum number to "max" An error occurred:

Error code: 1111. Invalid use of group function 0.000 seconds

SELECT max(count(*)) as max
FROM ticket
group by fan_fan_id;

I'm not sure what the problem is here and I'd be happy to get some help here - and I need to fix it without the "limit 1" option

P粉139351297
P粉139351297

reply all(1)
P粉949267121

SQL does not allow nested aggregate functions like the example you have shown.

The parameters of aggregate functions must be scalar expressions, not aggregate expressions.

You can do what you want:

SELECT MAX(c) FROM (SELECT COUNT(*) AS c FROM ticket GROUP BY fan_fan_id) AS t;

Or another way is to sort by value in descending order and return only the first count:

SELECT COUNT(*) AS c FROM ticket GROUP BY fan_fan_id ORDER BY c DESC LIMIT 1;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template