从子查询组中选择最大值

时间:2015-07-13 22:54:39

标签: mysql

是否可以选择子查询的最大值。我尝试了以下SELECT MAX(SELECT COUNT(lid)AS count FROM Lessons GROUP BY day),但它显然失败了。有什么建议吗?

enter image description here

2 个答案:

答案 0 :(得分:2)

为什么不

SELECT COUNT(lid) AS count 
FROM Lessons 
GROUP BY day
ORDER BY count desc
limit 1

答案 1 :(得分:1)

SELECT MAX(myCount) FROM (SELECT COUNT(lid) AS myCount FROM Lessons GROUP BY day) AS sub Query

我相信这就是你要找的东西。