-4

我想要一个简单的查询来获得一些输出。记录是

ID      Count
215     1
215     1
215     1
215     1

输出必须是

ID   Count
215  4
4

3 回答 3

3
SELECT ID, COUNT(*) AS Count
FROM tablename
GROUP BY ID
于 2013-07-17T09:48:08.337 回答
3

很简单,

SELECT ID ,COUNT(*) AS CNT
FROM TABLE_NAME
GROUP BY ID
于 2013-07-17T09:49:46.740 回答
-1
SELECT ID, sum(Count) AS Count
FROM tablename
GROUP BY ID
于 2013-07-17T09:50:21.540 回答