我想显示所有项目,首先显示项目最多的特殊项目,并且它们必须按特殊分组。
[id] [specials_id] [item]
1 1 bread
2 2 bread
3 2 eggs
4 1 peanut
5 2 macaroni
6 3 peanut
7 2 juice
结果应该是这样的:
2 bread
2 eggs
2 macaroni
2 juice
1 bread
1 peanut
3 peanut
我试过这个,但它只返回其中一个:
SELECT COUNT(*) AS `Rows`, item, special_id
FROM my_table
GROUP BY special_id
ORDER BY `Rows` DESC
有人可以帮助我吗?