我有一个表格'workers',其中包含类似的数据
name | category
----------------------
Steve | A
Anne | B
Linda | A
...等等
我想大致了解类别(类别数)以及整个计数。
查询
SELECT category, COUNT(category) AS number_of_people
FROM workers
GROUP BY category
将我带到这里:
category | number_of_people
----------------------------------
A | 2
B | 1
但是我想要的输出将是这样的:
category | number_of_people
----------------------------------
A | 2
B | 1
-----------------------------------
TOTAL | 3
我正在使用MS Access。
答案 0 :(得分:1)
使用联合
SELECT category, COUNT(category) AS number_of_people
FROM workers
GROUP BY category
union
SELECT 'total', COUNT(category) AS number_of_people
FROM workers