我正在尝试使用GROUPBY在ms access中编写一个查询,结果是两个组的计数,然后是剩余组的总和。因此,如果我有一个字段颜色和18个项目,并按颜色对项目进行计数,我将得到以下结果:
red = 6 green = 3 orange = 2 blue = 3 yellow = 4
不过,我要找的是:
red = 6 green = 3 All other colors = 9
不知道如何为此编写sql。请告知。谢谢
2wnc66cl1#
考虑:
SELECT Count(*) AS CntColor, Switch([Color]="Red","Red",[Color]="Green","Green",True,"Other") AS ColorGrp FROM Table1 GROUP BY Switch([Color]="Red","Red",[Color]="Green","Green",True,"Other");
1条答案
按热度按时间2wnc66cl1#
考虑: