SuperZhang的网络笔记本。

sql 给结果计数,并找出最大值

作者:share 发布于:2019-12-23 15:37 分类:数据库

SELECT any_value(moderator) AS moderator,MAX(count) as count FROM (SELECT moderator,COUNT(*) as count  FROM `data` WHERE `name`= :inputName GROUP BY moderator ORDER BY count DESC) a ";
           
结构为单表,inputname为查询条件名词。
语句有缺陷,一样大小的count值只会取排序的第一个

发表评论:

Powered by emlog