我的输入如下,并希望使用MS Access和SQL语句实现以下输出。我有超过10,000行的“机器名称”和100万行“Serial #s”,但是想根据机器名称对序列号进行计数:
输入:
Machine Name | Serial #
ALPHA0101 | K3332293
ALPHA0101 | L6569866
ALPHA0101 | R6889533
ALPHA0101 | H556565
ALPHA0101 | H353565
ALPHA0102 | W323232
ALPHA0102 | R656986
ALPHA0102 | I3232323
预期产出:
Machine Name | Count of Serial #s
ALPHA0101 | 5
ALPHA0102 | 3
谢谢!
答案 0 :(得分:2)
SELECT [Machine Name], COUNT(*) AS [Count of Serial #s]
FROM MyTable
GROUP BY [Machine Name]