简单的SQL Excel计数

时间:2014-08-28 15:54:25

标签: sql ms-access count distinct

我的输入如下,并希望使用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

谢谢!

1 个答案:

答案 0 :(得分:2)

SELECT [Machine Name], COUNT(*) AS [Count of Serial #s]
FROM MyTable
GROUP BY [Machine Name]