这里还有其他听起来相似但不是的问题。我有一个查询,它返回一堆带有 group by 的行,我想对总 group by 行应用限制,而不是用于创建组的总行数。
ID TYPE COLOR SIZE
----------------------------------------
1 Circle Blue Large
2 Circle Red Large
3 Square Green Large
4 Circle Purple Large
5 Circle Blue Small
6 Circle Yellow Medium
7 Circle Black Large
8 Oval Blue Large
9 Circle Gray Small
10 Triangle Black Large
11 Star Green Large
12 Triangle Purple Large
SELECT size, type FROM clothes WHERE size = 'large' GROUP BY type LIMIT 0, 5
TYPE SIZE ROWS
---------------------------
Circle Large 4
Square Large 1
^^^^ 2 组按行已经用尽了我的限制
TYPE SIZE ROWS
---------------------------
Circle Large 4
Square Large 1
Oval Large 1
Triangle Large 2
Star Large 1
^^^^ 这是我想要的,限制适用于组
必须有一些子查询或我可以在这里做的事情,但我没有弄清楚。
谢谢。